Skip to content

Stop forwarding SDK location defaults to MSBuild - #57174

Open
baronfel wants to merge 5 commits into
dotnet:release/11.0.2xxfrom
baronfel:baronfel-remove-msbuild-sdk-path-vars
Open

baronfel wants to merge 5 commits into
dotnet:release/11.0.2xxfrom
baronfel:baronfel-remove-msbuild-sdk-path-vars

Conversation

@baronfel

@baronfel baronfel commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Let MSBuild discover SDK locations from the selected toolset instead of generating MSBuildExtensionsPath and MSBuildSDKsPath environment variables. Preserve explicit overrides and DOTNET_HOST_PATH.
  • Remove the MSBuildExtensionsPath global-property defaults used by run/MTP evaluation and run telemetry.
  • Add nested SDK-selection, direct evaluation, override, worker-node, run, and MTP regression coverage; document the discovery contract.

An older parent CLI can still pass stale SDK-path values to a newer child. The child preserves them because it cannot distinguish them from intentional overrides.

Validation

  • Full Debug redist build and Native AOT test publish succeeded on Windows x64.
  • Focused managed tests: 26 passed, 1 skipped; Native AOT evaluation tests: 4 passed.
  • Repeated server-enabled requests passed, but reuse of the same server process was not verified. Other operating systems were not tested locally.

Closes dotnet/msbuild#14701
Relates to #55772.

@baronfel
baronfel requested review from a team as code owners November 17, 2026 16:58
Copilot AI balanced review requested due to automatic review settings November 17, 2026 16:58
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Missing regression coverage for nonzero telemetry reference counts after an actual project-based run with SDK-path defaults removed and an explicit extensions-path override leaves swallowed evaluation failures undetected.

1 open issue
What changed in this PR

This PR lets MSBuild discover SDK locations from its selected toolset, preventing CLI-generated defaults from interfering with nested invocations that select another SDK. Explicit overrides and DOTNET_HOST_PATH remain preserved.

Changes:

  • Remove SDK-path environment defaults and the extensions-path global default used by run/MTP evaluation and run telemetry.
  • Add or update coverage for nested SDK selection, worker nodes, direct evaluation, overrides, run, MTP, and Native AOT forwarding.
  • Document discovery behavior, inherited-override limitations, and test-environment requirements.
File Description
test/​TestAssets/​TestProjects/​MSBuildSdkDiscovery/​Sdks/​Discovery.Sdk/​Sdk/​Sdk.targets Supplies minimal custom SDK targets.
test/​TestAssets/​TestProjects/​MSBuildSdkDiscovery/​Sdks/​Discovery.Sdk/​Sdk/​Sdk.props Records the resolved custom SDK path.
test/​TestAssets/​TestProjects/​MSBuildSdkDiscovery/​Program.cs Adds a file-based run fixture.
test/​TestAssets/​TestProjects/​MSBuildSdkDiscovery/​Probe.proj Probes toolset paths, nested invocations, and worker execution.
test/​TestAssets/​TestProjects/​MSBuildSdkDiscovery/​Override.proj Exercises explicit SDK and extensions overrides.
test/​TestAssets/​TestProjects/​MSBuildSdkDiscovery/​Extensions/​Discovery.props Records the resolved extensions path.
test/​TestAssets/​TestProjects/​MSBuildSdkDiscovery/​Directory.Build.targets Detects SDK-path environment leakage during build and run evaluation.
test/​Microsoft.NET.TestFramework/​SdkTestContext.cs Removes initialization of the deleted extensions-path test hook.
test/​dotnet.Tests/​CommandTests/​Test/​GivenDotnetTestProducesBinaryLog.cs Runs MTP coverage without harness-supplied SDK paths.
test/​dotnet.Tests/​CommandTests/​Run/​RunCommandTests.cs Checks property preservation and clean-environment run evaluation.
test/​dotnet.Tests/​CommandTests/​MSBuild/​GivenMSBuildSdkDiscovery.cs Adds discovery and override regression scenarios.
test/​dotnet.Tests/​CommandTests/​MSBuild/​GivenMsbuildForwardingApp.cs Verifies forwarding preserves overrides without generating defaults.
test/​dotnet-aot.Tests/​MSBuildEvaluationTests.cs Updates Native AOT forwarding expectations.
src/​Cli/​Microsoft.DotNet.Cli.Utils/​MSBuildForwardingAppWithoutLogging.cs Stops supplying SDK-path environment defaults.
src/​Cli/​dotnet/​Commands/​Run/​RunCommand.cs Removes the extensions-path default from telemetry evaluation.
src/​Cli/​dotnet/​Commands/​Run/​CommonRunHelpers.cs Preserves caller properties without adding an extensions-path default.
src/​Cli/​dotnet-aot/​SdkRootResolution.md Documents forwarding behavior and corrects the component name.
documentation/​project-docs/​developer-guide.md Documents the discovery contract and test isolation requirements.

Review effort: Balanced

@Evangelink Evangelink left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This review was AI-generated.

Two additional test issues are noted inline. The project-based telemetry evaluation coverage gap is already reported in an existing Copilot review comment and is not duplicated here.


<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this snapshot change expected?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the branch flow. The equivalent fix merged into release/11.0.1xx in #57175, but it has not reached release/11.0.2xx yet. The open 1xx → 2xx merge PR #56929 predates the fix and still has the old snapshot; the current 2xx VMR backflow PR #57132 also lacks it. Once the 1xx → 2xx flow is updated and merged, I expect a rebase to make this snapshot diff unnecessary. For now, this PR keeps the snapshot update so its CI passes.

@baronfel
baronfel force-pushed the baronfel-remove-msbuild-sdk-path-vars branch from da3ea7e to 6b13edb Compare November 19, 2026 21:24
baronfel and others added 4 commits November 20, 2026 15:55
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep alternate SDK files at a distinct physical path, normalize macOS temp paths, and refresh the F# sample approval.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@baronfel
baronfel force-pushed the baronfel-remove-msbuild-sdk-path-vars branch from 6b13edb to 6139072 Compare November 20, 2026 21:55
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-dotnet AOT Items that are part of the dotnet CLI AOT-ification effort Area-MSBuild

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants