question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

C# Extension Thinks I have Visual Studio 2019 Installed

See original GitHub issue

Issue 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

  1. Install Windows 11
  2. Install Visual Studio 2022 Community
  3. Install Visual Studio Code
  4. Install C# extension
  5. 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

Starting OmniSharp server at 08/04/2022, 12:09:33 pm Target: e:\Code\Xous\Core

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(IEnumerable1 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(IEnumerable1 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: ef40e6aa06

Runtime 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:open
  • Created a year ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
filipwcommented, Apr 8, 2022

It looks like modern .NET doesn’t work at all:

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.

0reactions
xobscommented, Apr 9, 2022

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, but OmniSharp 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Visual Studio installation and upgrade issues
This troubleshooting guide includes step-by-step instructions that should resolve most installation issues.
Read more >
Visual Studio 2019 This extension is not installable on any ...
After I updated the manifest file in the VSIX I was able to install this extension using the updated VSIXInstaller.exe application that was ......
Read more >
Managing Extensions in Visual Studio Code
You can install, disable, update, and uninstall extensions through the Extensions view, the Command Palette (commands have the Extensions: prefix) or command- ...
Read more >
Compile and run C code using Visual Studio Code (2021)
Link to download the Visual Studio Code IDE and Visual C / C++ compiler: https:// visualstudio.microsoft.com/downloadsCheck out our Discord ...
Read more >
ReSharper is not available in Visual Studio after installation
Check if "JetBrains ReSharper" extensions is available at the VS' Extensions | Manage Extensions | Installed but disabled. Enable it back, if so ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found