Skip to content

Set DOTNET_HOST_PATH from property after MSBuildSdkResolver resolution #12017

@surayya-MS

Description

@surayya-MS

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 DOTNET_EXPERIMENTAL_HOST_PATH set incorrectly with SDK hint paths sdk#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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions