Skip to content

SdkResolver-provided env vars should take precedence over the ambient environment #12654

@baronfel

Description

@baronfel

Summary

Today the SdkResolver system can provide environment variables to the engine when an SDK is resolved. The primary usage of this feature is

  • to keep invocations of the SDK unified across MSBuild-driven tooling via the DOTNET_HOST_PATH environment variable
  • to drive usage of the .NET TaskHost feature for spawning .NET-targeted MSBuild tasks in a .NET TaskHost from a .NET Framework central node

However, the variables provided by this mechanism are currently overridden by ambient environment variables taken from the snapshot of the host process at the time the build is started. This means that external processes can override the SdkResolver's decisions.

Background and Motivation

Internal users are having some churn in mixed VS installs and need to set DOTNET_HOST_PATH in older VS environments to mitigate that churn, but want to defer to this feature in dev18 onwards by default.

Proposed Feature

We want the resolver to be the complete source of truth, so we should change the way the SdkResolver env vars are applied to the overall environmental state. The SdkResolver env vars should override any ambient env vars.

We need to make this change, update the existing tests, and add new tests pinning this behavior.

Alternative Designs

No response

Metadata

Metadata

Assignees

Labels

Area: ApplicationIssues with `msbuild.exe` or the CLI experience.Area: ResolversArea: Visual StudioIssues related to interactions with Visual Studio or project systems.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions