After a lot of troubleshooting, I've decided to post this here. When opening a .NET Core 8 project in VSCode with the C# Dev Kit extension installed, I receive errors that the SDK cannot be located. This is the full output from the extension:
Starting opening a solution...
Starting processing the solution file "/Users/chaueisen-yates/Projects/Online Banking/WebE2E/WebE2E.sln" in Dev Kit server...
Failed to find dotnet from path with "which dotnet".
Cannot find .NET SDK installation from PATH environment. C# DevKit extension would not work without a proper installation of the .NET SDK accessible through PATH environment. Rebooting might be necessary in some cases. Check the PATH environment logged in the C# DevKit logging window. In some cases, it could be affected how VS code was started.
PATH=/usr/bin:/bin:/usr/sbin:/sbin
Using local .NET runtime at "/Users/chaueisen-yates/Library/Application Support/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/8.0.10~arm64~aspnetcore/dotnet"
.NET server started and IPC established in 545ms
Completed Spawn .NET server (975ms)
Completed processing the solution file "/Users/chaueisen-yates/Projects/Online Banking/WebE2E/WebE2E.sln" in Dev Kit server (1153ms)
Starting restoring NuGet packages...
Selected configuration: <Default>, active configuration: Debug|Any CPU
Completed opening a solution (1157ms)
Starting command: "dotnet" restore /Users/chaueisen-yates/Projects/Online Banking/WebE2E/WebE2E.sln --interactive...
Failed to monitor project loading status.
Starting Query for all projects...
Failed at 'Query for all projects' (39ms) with error: Error: Exception while talking to proxy: Error: One or more errors occurred. (No installed .NET SDK was found on the computer. If it is installed, make sure it can be found through the PATH environment variable.)
The issue in this case is that the correct PATH variable is not being found or used by the extension process. In my case, I'm running MacOS Sonoma (Latest) and VSCode Release. I did try a fresh install of VSCode Insiders and only installed the C# Dev Kit extension, but the PATH came back the same as above.
My PATH, when queried from a fresh MacOS Terminal is:
This happens when opening VSCode from the Dock in MacOS. As I understand it, VSCode does not necessarily provide the correct path unless spawned from a terminal process which carries that PATH, i.e from the code command. Opening my project this way resolves the issue, however it is not the solution in my opinion.
This may be a greater underlying issue with VSCode as a whole, but there is seemingly no clear-cut way to override the DevKit extension's SDK locating mechanism. I have added and tweaked custom SDK path overrides to most of the different places you can do so in C# DevKit, C#, and .NET Install Tool's settings pages and no combination of these override the PATH being used or the result of the locating process
Regardless of if this is an issue with the extension or if it's an issue to be taken up with the VSCode project, I would think any settings overrides would supersede the default "which dotnet" behavior.
Steps To Reproduce
Install the latest .NET Core SDK from the installer on the website
Install VSCode on MacOS via the download on the website
Open VSCode and install the C# DevKit Extension
Open a .NET Core project folder
Error shown above populates the C# DevKit output
Expected Behavior
I would expect either VSCode to provide, or C# DevKit to locate, the correct PATH variable with the .NET Core SDK in it
If that fails, I would expect C# DevKit to either use existing override settings or create a newer unified override setting for finding the SDK.
Environment Information
OS: MacOS Sonoma 14.5 on Macbook Pro M3
VSCode Versions: 1.94.2 (Universal) & Tested on 1.95.0-insider (Universal)
C# DevKit Extension Versions: v1.11.14 & Tested on v1.12.2 (pre-release)
Adding @lifengl for SDK lookup logic, but I agree that vscode does not always get the correct PATH and most likely we would want to raise a bug on the vscode side as I dont see any other escapes here.
Describe the Issue
After a lot of troubleshooting, I've decided to post this here. When opening a .NET Core 8 project in VSCode with the C# Dev Kit extension installed, I receive errors that the SDK cannot be located. This is the full output from the extension:
The issue in this case is that the correct PATH variable is not being found or used by the extension process. In my case, I'm running MacOS Sonoma (Latest) and VSCode Release. I did try a fresh install of VSCode Insiders and only installed the C# Dev Kit extension, but the PATH came back the same as above.
My PATH, when queried from a fresh MacOS Terminal is:
This happens when opening VSCode from the Dock in MacOS. As I understand it, VSCode does not necessarily provide the correct path unless spawned from a terminal process which carries that PATH, i.e from the
code
command. Opening my project this way resolves the issue, however it is not the solution in my opinion.This may be a greater underlying issue with VSCode as a whole, but there is seemingly no clear-cut way to override the DevKit extension's SDK locating mechanism. I have added and tweaked custom SDK path overrides to most of the different places you can do so in C# DevKit, C#, and .NET Install Tool's settings pages and no combination of these override the PATH being used or the result of the locating process
Regardless of if this is an issue with the extension or if it's an issue to be taken up with the VSCode project, I would think any settings overrides would supersede the default "
which dotnet
" behavior.Steps To Reproduce
Expected Behavior
Environment Information