Skip to content

feat(ir): add typed builder for UseDotNet@2#1150

Merged
jamesadevine merged 1 commit into
mainfrom
feat/ir-use-dotnet-v2-e765d7317af3b9fb
Jun 22, 2026
Merged

feat(ir): add typed builder for UseDotNet@2#1150
jamesadevine merged 1 commit into
mainfrom
feat/ir-use-dotnet-v2-e765d7317af3b9fb

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Adds a typed builder struct for UseDotNet@2 to the ado-aw IR, and migrates the stringly-typed dotnet_install_task_step factory in src/runtimes/dotnet/extension.rs.

Motivation

Previously, the .NET runtime extension emitted the UseDotNet@2 step via raw TaskStep::new("UseDotNet@2", ...).with_input("packageType", "sdk").with_input(...) calls. This PR introduces a typed builder so required inputs are positional, optional inputs are type-checked, and the PackageType constraint ("sdk" / "runtime") is modelled as an enum rather than a stringly-typed key.

Changes

  • src/compile/ir/tasks/use_dotnet.rs: new UseDotNet builder struct with PackageType enum, convenience constructors (with_version / with_global_json), typed optional setters, and #[cfg(test)] mod tests (11 unit tests)
  • src/compile/ir/tasks/mod.rs: pub mod use_dotnet; declaration (alphabetical order)
  • src/runtimes/dotnet/extension.rs: migrated dotnet_install_task_step from raw TaskStep::new to UseDotNet::with_global_json() / UseDotNet::with_version(), added use_dotnet::UseDotNet import
  • src/compile/extensions/tests.rs: updated two assertions that expected the now-omitted explicit packageType: sdk (the ADO default is "sdk", so the typed builder correctly omits it to keep generated YAML minimal)

ADO Task Reference

  • Task: UseDotNet@2
  • Docs: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/use-dotnet-v2-task
  • Required inputs: (none — all inputs are optional)
  • Optional inputs: version, packageType (PackageType enum), useGlobalJson, workingDirectory, installationPath, performMultiLevelLookup, failOnStandardError

Builder modes

// Version spec mode
UseDotNet::with_version("8.0.x").into_step()

// global.json mode
UseDotNet::with_global_json()
    .with_display_name("Install .NET SDK (from global.json)")
    .into_step()

// Runtime (not SDK)
UseDotNet::with_version("8.0.x")
    .package_type(PackageType::Runtime)
    .into_step()

Validation

  • cargo build --all-targets
  • cargo test (2133 tests pass, 0 failed)
  • cargo clippy --all-targets --all-features --workspace -- -D warnings

Created by the ado-task-ir-contributor workflow.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • spsprodeus21.vssps.visualstudio.com
  • spsprodweu4.vssps.visualstudio.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "spsprodeus21.vssps.visualstudio.com"
    - "spsprodweu4.vssps.visualstudio.com"

See Network Configuration for more information.

Generated by ADO Task IR Contributor · 866.1 AIC · ⌖ 19.2 AIC · ⊞ 38K ·

Add `use_dotnet::UseDotNet` builder struct with a `PackageType` enum and
migrate the stringly-typed `dotnet_install_task_step` in
`runtimes/dotnet/extension.rs` from raw `TaskStep::new("UseDotNet@2", …)`
calls to the new typed builder.

The builder supports both .NET installation modes:
- Version spec mode: `UseDotNet::with_version("8.0.x")`
- Global-json mode: `UseDotNet::with_global_json()`

All optional inputs (`packageType`, `workingDirectory`, `installationPath`,
`performMultiLevelLookup`, `failOnStandardError`) are only emitted when
explicitly set; the ADO defaults apply otherwise, keeping generated YAML
minimal. Since the ADO default for `packageType` is `"sdk"`, the migration
stops emitting the now-redundant explicit `packageType: sdk` — two existing
tests that asserted on this explicit input are updated accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jamesadevine jamesadevine marked this pull request as ready for review June 22, 2026 14:33
@jamesadevine jamesadevine merged commit da3c645 into main Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant