microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
221 stars 10 forks source link

[BUG] dotnet location not respecting `existingDotnetPath` #1466

Open rithvik-bosch opened 1 week ago

rithvik-bosch commented 1 week ago

Describe the Issue

dotnet installed in Program Files only has sdk 6, while I need 8. Without admin rights, it's not possible to install sdk 8 in it. So I'm trying to set a custom location for the dotnet SDK.

It seems like the new location is picked up but nuget still uses the dotnet.exe from PATH (which I can't modify since it's a system env var).

Specifically this line: Found installed dotnet location "C:\Program Files\dotnet\dotnet.exe" to load projects. is not respecting the custom location C:\Users\username\AppData\Local\dotnet-sdk-8.0.401-win-x64\dotnet.exe

Steps To Reproduce

SDK 6 installed at default location SDK 8 installed at a custom location vscode settings set:

{
  "dotnetAcquisitionExtension.sharedExistingDotnetPath": "C:\\Users\\username\\AppData\\Local\\dotnet-sdk-8.0.401-win-x64\\dotnet.exe",
  "dotnet.dotnetPath": "C:\\Users\\username\\AppData\\Local\\dotnet-sdk-8.0.401-win-x64",
  "dotnetAcquisitionExtension.existingDotnetPath": [
    {
      "extensionId": "ms-dotnettools.csdevkit",
      "path": "C:\\Users\\username\\AppData\\Local\\dotnet-sdk-8.0.401-win-x64\\dotnet.exe"
    },
    {
      "extensionId": "ms-dotnettools.vscodeintellicode-csharp",
      "path": "C:\\Users\\username\\AppData\\Local\\dotnet-sdk-8.0.401-win-x64\\dotnet.exe"
    },
    {
      "extensionId": "ms-dotnettools.csharp",
      "path": "C:\\Users\\username\\AppData\\Local\\dotnet-sdk-8.0.401-win-x64\\dotnet.exe"
    },
    {
      "extensionId": "ms-dotnettools.vscode-dotnet-runtime",
      "path": "C:\\Users\\username\\AppData\\Local\\dotnet-sdk-8.0.401-win-x64\\dotnet.exe"
    }
  ],
  "omnisharp.sdkPath": "C:\\Users\\username\\AppData\\Local\\dotnet-sdk-8.0.401-win-x64\\sdk\\8.0.401",
  "omnisharp.dotNetCliPaths": [
    "C:\\Users\\username\\AppData\\Local\\dotnet-sdk-8.0.401-win-x64\\dotnet.exe"
  ]
}

C# Dev Kit Log:

Starting Spawn .NET server...
Starting opening a solution...
Starting processing the solution file "c:\Users\username\Documents\Projects\project\.project.sln" in Dev Kit server...
Using local .NET runtime at "C:\Users\username\AppData\Local\dotnet-sdk-8.0.401-win-x64\dotnet.exe"
Found installed dotnet location "C:\Program Files\dotnet\dotnet.exe" to load projects.
.NET server started and IPC established in 1279ms
Completed Spawn .NET server (4834ms)
Completed processing the solution file "c:\Users\username\Documents\Projects\project\.project.sln" in Dev Kit server (6164ms)
Starting restoring NuGet packages...
Selected configuration: <Default>, active configuration: Debug|Any CPU
Completed opening a solution (6176ms)
Starting command: "dotnet.exe" restore C:\Users\username\Documents\Projects\project\.project.sln --interactive...
Failed at 'command: "dotnet.exe" restore C:\Users\username\Documents\Projects\project\.project.sln --interactive' (1113ms) with error: ExitCodeError: Failed with ExitCode(1)
Completed NuGet restore with error: DotnetCommandRestoreError: Failed with ExitCode(1)
Completed restoring NuGet packages (1117ms)

NuGet log:

  Determining projects to restore...
C:\Program Files\dotnet\sdk\6.0.424\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.  Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. [C:\Users\username\Documents\Projects\project\project\project.csproj]

Specifically this line: Found installed dotnet location "C:\Program Files\dotnet\dotnet.exe" to load projects. is not respecting the custom location C:\Users\username\AppData\Local\dotnet-sdk-8.0.401-win-x64\dotnet.exe

Expected Behavior

It should use C:\Users\username\AppData\Local\dotnet-sdk-8.0.401-win-x64\dotnet.exe.

Environment Information

nagilson commented 2 days ago

related https://github.com/dotnet/vscode-dotnet-runtime/issues/1824