msbuild
msbuild copied to clipboard
Set `DOTNET_HOST_PATH` from property after MSBuildSdkResolver resolution
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
- Properties
SdkResolverMSBuildTaskHostRuntimeVersionand formerDOTNET_EXPERIMENTAL_HOST_PATHshould be set not from thePATHbut fromresolverResult.ResolvedSdkDirectory. The new name forDOTNET_EXPERIMENTAL_HOST_PATHproperty should be smth likeSdkResolverDotnetHostPathToSet. see more in this bug https://github.com/dotnet/sdk/issues/49363. - 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.