msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Set `DOTNET_HOST_PATH` from property after MSBuildSdkResolver resolution

Open surayya-MS opened this issue 4 months ago • 1 comments

Currently, we add a property DOTNET_EXPERIMENTAL_HOST_PATH to SdkResult in MSBuildSdkResolver https://github.com/dotnet/sdk/blob/main/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs#L35

Instead it should be set from resolverResult.ResolvedSdkPath which I tried to do in this PR https://github.com/dotnet/sdk/pull/49391/files and should be available as DOTNET_HOST_PATH env var. We need it for compiler to be able to access DOTNET_HOST_PATH env var in Csc task https://github.com/dotnet/roslyn/blob/0256a957942e9605fc62eb917d0034db20cc1d1d/src/Compilers/Shared/RuntimeHostInfo.cs#L47

The new behavior should be

  1. Properties SdkResolverMSBuildTaskHostRuntimeVersion and former DOTNET_EXPERIMENTAL_HOST_PATH should be set not from the PATH but from resolverResult.ResolvedSdkDirectory. The new name for DOTNET_EXPERIMENTAL_HOST_PATH property should be smth like SdkResolverDotnetHostPathToSet. see more in this bug https://github.com/dotnet/sdk/issues/49363.
  2. The env var DOTNET_HOST_PATH (without _EXPERIMENTAL) should be set from that property on MSBuild side not inside the resolver. The reason for that is because we evaluate projects in parallel in many cases (graph build, VS solution load) and so the resolver shouldn't be setting global process state.

surayya-MS avatar Jun 13 '25 17:06 surayya-MS