C# Extension Thinks I have Visual Studio 2019 Installed
See original GitHub issueIssue Description
When opening a project, Visual Studio Code prints the following information:
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Community 2022 17.1.32328.378 17.1.0 - "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin"
2: StandAlone 17.1.1 - "c:\Users\Sean\.vscode\extensions\ms-dotnettools.csharp-1.24.3-win32-x64\.omnisharp\1.38.2\.msbuild\Current\Bin"
[warn]: OmniSharp.CompositionHostBuilder
It looks like you have Visual Studio 2019 installed without .NET Core SDK support which is required by OmniSharp.
Try updating Visual Studio 2019 installation with .NET Core SDK to enable better MSBuild support.
As you can see, the extension seems to think I have Visual Studio 2019 installed when in fact I do not. This is a fresh install of Windows 11, and has never had Visual Studio 2019 installed.
Furthermore, I installed .NET by going to the site opened by the extension: https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.201-windows-x64-installer?journey=vs-code
The extension then refuses to work.
Steps to Reproduce
- Install Windows 11
- Install Visual Studio 2022 Community
- Install Visual Studio Code
- Install C# extension
- Open a directory with a
.csproj
file in it.
Expected Behavior
Previously, the extension would open the project and allow me to auto-complete .cs
files in the directory.
Actual Behavior
The extension throws a lot of errors, such as:
C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): Error: The "ResolvePackageAssets" task failed unexpectedly.
NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages'.
Logs
OmniSharp log
OmniSharp server started. Path: c:\Users\Sean.vscode\extensions\ms-dotnettools.csharp-1.24.3-win32-x64.omnisharp\1.38.2\OmniSharp.exe PID: 20828
Starting OmniSharp on Windows 6.2.9200.0 (x64)
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
Using the 'dotnet' on the PATH.
DotNetPath set to dotnet
Located 2 MSBuild instance(s)
1: Visual Studio Community 2022 17.1.32328.378 17.1.0 - "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin"
2: StandAlone 17.1.1 - "c:\Users\Sean\.vscode\extensions\ms-dotnettools.csharp-1.24.3-win32-x64\.omnisharp\1.38.2\.msbuild\Current\Bin"
It looks like you have Visual Studio 2019 installed without .NET Core SDK support which is required by OmniSharp.
Try updating Visual Studio 2019 installation with .NET Core SDK to enable better MSBuild support.
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to ‘c:\Users\Sean.vscode\extensions\ms-dotnettools.csharp-1.24.3-win32-x64.omnisharp\1.38.2.msbuild\Current\Bin\MSBuild.exe’
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 17.1.1 - “c:\Users\Sean.vscode\extensions\ms-dotnettools.csharp-1.24.3-win32-x64.omnisharp\1.38.2.msbuild\Current\Bin”
CscToolExe = csc.exe
CscToolPath = c:\Users\Sean.vscode\extensions\ms-dotnettools.csharp-1.24.3-win32-x64.omnisharp\1.38.2.msbuild\Current\Bin\Roslyn
MSBuildExtensionsPath = c:\Users\Sean.vscode\extensions\ms-dotnettools.csharp-1.24.3-win32-x64.omnisharp\1.38.2.msbuild
MSBuildToolsPath = c:\Users\Sean.vscode\extensions\ms-dotnettools.csharp-1.24.3-win32-x64.omnisharp\1.38.2.msbuild\Current\Bin
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in ‘e:\Code\Xous\Core’.
info: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in ‘e:\Code\Xous\Core’
info: OmniSharp.MSBuild.ProjectManager
Queue project update for ‘e:\Code\Xous\Core\emulation\peripherals.csproj’
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in ‘e:\Code\Xous\Core’.
info: OmniSharp.MSBuild.ProjectManager
Loading project: e:\Code\Xous\Core\emulation\peripherals.csproj
info: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location ‘e:\Code\Xous\Core’ on host 10916.
fail: OmniSharp.MSBuild.ProjectLoader
The “ResolvePackageAssets” task failed unexpectedly.
NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder ‘C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages’.
at NuGet.Packaging.FallbackPackagePathResolver…ctor(String userPackageFolder, IEnumerable1 fallbackPackageFolders) at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(IEnumerable
1 packageFolders)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter…ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader…ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
warn: OmniSharp.MSBuild.ProjectManager
Failed to load project file ‘e:\Code\Xous\Core\emulation\peripherals.csproj’.
e:\Code\Xous\Core\emulation\peripherals.csproj
C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): Error: The “ResolvePackageAssets” task failed unexpectedly.
NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder ‘C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages’.
at NuGet.Packaging.FallbackPackagePathResolver…ctor(String userPackageFolder, IEnumerable1 fallbackPackageFolders) at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(IEnumerable
1 packageFolders)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter…ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader…ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Attempted to update project that is not loaded: e:\Code\Xous\Core\emulation\peripherals.csproj
Inlay hints requested for document not in workspace Location { FileName = e:\Code\Xous\Core\emulation\peripherals\ComSoC.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 126, Column = 0 } } }
Inlay hints requested for document not in workspace Location { FileName = e:\Code\Xous\Core\emulation\peripherals\ComSoC.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 99, Column = 0 } } }
Inlay hints requested for document not in workspace Location { FileName = e:\Code\Xous\Core\emulation\peripherals\ComSoC.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 103, Column = 0 } } }
Inlay hints requested for document not in workspace Location { FileName = e:\Code\Xous\Core\emulation\peripherals\ComSoC.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 104, Column = 9 } } }
C# log
The C# log is empty
Environment information
VSCode version: 1.66.1 C# Extension: 1.24.3
Dotnet Information
.NET SDK (reflecting any global.json): Version: 6.0.201 Commit: ef40e6aa06Runtime Environment: OS Name: Windows OS Version: 10.0.22000 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.201\
Host (useful for support): Version: 6.0.3 Commit: c24d9a9c91
.NET SDKs installed: 6.0.201 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions
Extension | Author | Version |
---|---|---|
better-cpp-syntax | jeff-hykin | 1.15.13 |
cmake | twxs | 0.0.17 |
cmake-tools | ms-vscode | 1.10.5 |
cpptools | ms-vscode | 1.9.7 |
cpptools-extension-pack | ms-vscode | 1.1.0 |
cpptools-themes | ms-vscode | 1.0.0 |
csharp | ms-dotnettools | 1.24.3 |
doxdocgen | cschlosser | 1.4.0 |
jupyter | ms-toolsai | 2022.3.1000901801 |
jupyter-keymap | ms-toolsai | 1.0.0 |
jupyter-renderers | ms-toolsai | 1.0.6 |
markdown-all-in-one | yzhang | 3.4.0 |
python | ms-python | 2022.4.1 |
remote-containers | ms-vscode-remote | 0.231.4 |
remote-ssh | ms-vscode-remote | 0.78.0 |
remote-ssh-edit | ms-vscode-remote | 0.80.0 |
remote-wsl | ms-vscode-remote | 0.66.0 |
vscode-pylance | ms-python | 2022.4.0 |
Issue Analytics
- State:
- Created a year ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
Because it is currently opt-in, the .NET 6.0 build of OmniSharp is not packaged with the extension and instead acquired on demand. Once you set the flag in the config, uninstall and install the extension again, and restart VS Code to force the download of this dependency.
It did install, after I removed the extension and re-added it. The issue is that when I set
omnisharp.useModernNet: true
I was given the option to restart VS Code, butOmniSharp for Windows (.NET 6 / x64)
was not downloaded. Instead, the user needs to remove the entire extension and re-install it with the setting already enabled.It was surprising behavior, but if it’s expected then it doesn’t warrant opening an issue. Particularly since that it will default to using that method in the future.