dotnet / dotnet/vscode-csharp

C# extension fails to find dotnet after downloading it

Open
#7,088 2 comments 0 reactions 0 assignees View on GitHub
Backlog Triaged
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
18h 40m
Merged PRs (30d)
31

Description

## Environment data
`dotnet --info` output: N/A
VS Code version: 1.89.0
C# Extension version: v2.23.15

## OmniSharp log

```
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
Error running dotnet --info: Error: Command failed: dotnet --info
'dotnet' is not recognized as an internal or external command,
operable program or batch file.

'dotnet' is not recognized as an internal or external command,
operable program or batch file.

Dotnet path: c:\Users\redacted\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\8.0.4~x64\dotnet.exe
Activating C# standalone...
waiting for named pipe information from server...
[stdout] {"pipeName":"\\\\.\\pipe\\1d1ad572"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info - 4:04:15 PM] [Program] Language server initialized
[Info - 4:04:15 PM] [LanguageServerProjectSystem] Loading c:\Users\redacted\source\repos\samples\basic-spike\parent\MyService.sln...
[Error - 4:04:15 PM] [LanguageServerHost] System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'dotnet.exe' with working directory 'C:\Users\redacted\AppData\Local\Programs\Microsoft VS Code'. The system cannot find the file specified.
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostAsync(BuildHostProcessKind buildHostKind, CancellationToken cancellationToken) in /_/src/Workspaces/Core/MSBuild/MSBuild/BuildHostProcessManager.cs:line 93
at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.OpenSolutionAsync(String solutionFilePath) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 100
at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.OpenSolutionAsync(String solutionFilePath) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 116
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 157
```

## Steps to reproduce

1. Remove dotnet from PATH
2. Activate C# extension
3. Look at output in C# output pane
4. See error

## Expected behavior
My team is developing a new VS Code extension and we want to take a dependency on the C# extension to execute dotnet commands on the user's project. I was testing what would happen if a user doesn't have dotnet pre-installed on the machine. I would expect the extension to restore the missing dotnet binary at activation time and continue to function as normal.

## Actual behavior
Even though it looks like the extension puts dotnet in the globalStorage\ms-dotnettools.vscode-dotnet-runtime folder, I consistently get the error shown above and am unable to debug my project.

## Additional context
N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.