roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

Local SDK installation fails to use correct dotnet host

Open rainersigwald opened this issue 7 months ago • 1 comments

Version Used: .NET SDK 10.0.100-preview.6.25302.104

Steps to Reproduce:

  1. Use an SDK hint path to point to a local preview.6 SDK
  2. Use Visual Studio (int preview channel) to build
  3. Work around https://github.com/dotnet/sdk/issues/49363

Diagnostic Id:

none

Expected Behavior:

path\to\local\sdk\dotnet.exe path\to\local\sdk\sdk\{version}\Roslyn\bincore\vbcscompiler.dll launches and handles compilation.

Actual Behavior:

error : 
error : App: S:\msbuild\.dotnet\sdk\10.0.100-preview.6.25302.104\Roslyn\bincore\csc.dll
error : Architecture: x64
error : Framework: 'Microsoft.NETCore.App', version '10.0.0-preview.6.25302.104' (x64)
error : .NET location: C:\Program Files\dotnet\
error : 
error : The following frameworks were found:
error :   6.0.36 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
error :   8.0.16 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
error :   8.0.17 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
error :   9.0.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
error :   9.0.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
error :   9.0.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
error :   10.0.0-preview.5.25277.114 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

When trying to figure out what dotnet.exe to use, there's a check for DOTNET_EXPERIMENTAL_HOST_PATH, but it is as an environment variable, when the SDK resolver sets it as a per-project MSBuild property.

https://github.com/dotnet/roslyn/blob/0256a957942e9605fc62eb917d0034db20cc1d1d/src/Compilers/Shared/RuntimeHostInfo.cs#L47

That property will need to be passed into the Csc task explicitly, or the SDK/task contract renegotiated.

rainersigwald avatar Jun 12 '25 15:06 rainersigwald

I could swear I saw it being set as an environment variable when debugging our build task and hence that it worked. But it's possible I just assumed that and setup my testing accordingly.

jjonescz avatar Jun 13 '25 08:06 jjonescz

Current thinking is that this will be resolved on the msbuild / sdk side by exposing everything as %DOTNET_HOST_PATH%. Keeping this open as a tracking item. May allow us to delete code once this is in place.

jaredpar avatar Jun 30 '25 18:06 jaredpar