Omnisharp-vscode: Problem after update to .NET SDK 2.2.202-1

Created on 4 Apr 2019  Â·  31Comments  Â·  Source: OmniSharp/omnisharp-vscode

Issue Description

Running into error after updating .NET SDK to 2.2.202-1 via Update Manager in Linux Mint 19.1.

Steps to Reproduce

From command line enter "dotnet new webapi -o TodoApi3", then "cd TodoApi3", then "code ." to open project in VS Code.

Expected Behavior

Message in VS Code asking if I want to add required assets to project.

Actual Behavior

Message: "Some projects have trouble loading. Please review the output for more details. Source: C# (Extension)"

It appears that the .vscode directory doesn't get created, along with files launch.json and tasks.json. Workaround is to manually copy those from a prior project and fix the content of the two files to match the project name.

Logs

OmniSharp log


Starting OmniSharp server at 4/4/2019, 4:04:54 PM
Target: /home/bob/projects/TodoApi3

OmniSharp server started.
Path: /home/bob/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/run
PID: 9615

    Starting OmniSharp on linuxmint 19.1 (x64)
    DotNetPath set to dotnet
    Located 1 MSBuild instance(s)
        1: StandAlone 15.0 - "/home/bob/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/omnisharp/msbuild/15.0/Bin"
    MSBUILD_EXE_PATH environment variable set to '/home/bob/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/omnisharp/msbuild/15.0/Bin/MSBuild.dll'
    Registered MSBuild instance: StandAlone 15.0 - "/home/bob/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/omnisharp/msbuild/15.0/Bin"
        MSBuildExtensionsPath = /home/bob/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/omnisharp/msbuild
        BypassFrameworkInstallChecks = true
        CscToolPath = /home/bob/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/omnisharp/msbuild/15.0/Bin/Roslyn
        CscToolExe = csc.exe
        MSBuildToolsPath = /home/bob/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/omnisharp/msbuild/15.0/Bin
    Detecting Cake files in '/home/bob/projects/TodoApi3'.
    Could not find any Cake files
    Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
    No solution files found in '/home/bob/projects/TodoApi3'
    Queue project update for '/home/bob/projects/TodoApi3/TodoApi3.csproj'
    Detecting CSX files in '/home/bob/projects/TodoApi3'.
    Could not find any CSX files
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
    Configuration finished.
    Omnisharp server running using Stdio at location '/home/bob/projects/TodoApi3' on host 9534.
    Loading project: /home/bob/projects/TodoApi3/TodoApi3.csproj
    Failed to load project file '/home/bob/projects/TodoApi3/TodoApi3.csproj'.

/home/bob/projects/TodoApi3/TodoApi3.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. /home/bob/projects/TodoApi3/TodoApi3.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.VerifyThrowInvalidProject[T1] (System.Boolean condition, System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00003] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.Collections.Generic.List1[Microsoft.Build.Construction.ProjectRootElement]& projects, System.Boolean throwOnFileNotExistsError) [0x00254] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00024] in <2338fdb301034c1d9c6b95e564d514b0>:0 at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <2338fdb301034c1d9c6b95e564d514b0>:0 at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].Evaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Framework.BuildEventContext buildEventContext) [0x00103] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCache projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.Execution.ProjectInstance projectInstanceIfAnyForDebuggerOnly, Microsoft.Build.BackEnd.SdkResolution.ISdkResolverService sdkResolverService, System.Int32 submissionId, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0001a] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0004c] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00034] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00023] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Project.Initialize (System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00126] in <2338fdb301034c1d9c6b95e564d514b0>:0 at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0009e] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f5] in <2338fdb301034c1d9c6b95e564d514b0>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003f] in :0
at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in :0
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectLoader loader) [0x00015] in :0
at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass28_0.b__0 () [0x00000] in :0
at (wrapper delegate-invoke) System.Func1[System.ValueTuple3[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray1[OmniSharp.MSBuild.Logging.MSBuildDiagnostic],OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs]].invoke_TResult() at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func1[TResult] loader) [0x0001b] in :0

    Attempted to update project that is not loaded: /home/bob/projects/TodoApi3/TodoApi3.csproj

C# log

(nothing)

Environment information

VSCode version: 1.32.3
C# Extension: 1.18.0

Mono Information
OmniSharp using built-in mono

Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 2.2.202
Commit: 8a7ff6789d

Runtime Environment:
OS Name: linuxmint
OS Version: 19.1
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/2.2.202/

Host (useful for support):
Version: 2.2.3
Commit: 6b8ad509b6

.NET Core SDKs installed:
2.1.602 [/usr/share/dotnet/sdk]
2.2.202 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download


Visual Studio Code Extensions

|Extension|Author|Version|
|---|---|---|
|Angular2|johnpapa|7.0.1|
|angular2-switcher|infinity1207|0.2.0|
|auto-rename-tag|formulahendry|0.0.15|
|chilly-vscode-dark-theme|ZachTRice|0.1.5|
|csharp|ms-vscode|1.18.0|
|csharpextensions|jchannon|1.3.0|
|debugger-for-chrome|msjsdiag|4.11.3|
|material-icon-theme|PKief|3.7.0|
|ng-template|Angular|0.1.11|
|path-intellisense|christian-kohler|1.4.2|
|Theme-Oblivion|gerane|0.0.2|
|vscode-angular2-files|alexiv|1.6.2|
|vscode-nuget-package-manager|jmrog|1.1.6|;

.Net sdk not found

Most helpful comment

For anyone trying to fix this quickly:

$ apt-cache policy dotnet-sdk-2.2 

dotnet-sdk-2.2:
  Installed: 2.2.202-1
  Candidate: 2.2.202-1
  Version table:
... 

which is followed by the list of versions

$ sudo apt install dotnet-sdk-2.2=<your version of choice>
for me it was

$ sudo apt install dotnet-sdk-2.2=2.2.105-1

and confirm the downgrade

All 31 comments

I can confirm..
Many of my projects used to work until I updated to 2.2.202-1 today;
Seeing a missing "Microsoft.NET.Sdk'" in my console apps or "'Microsoft.NET.Sdk.Web' in my web apps...

This is a known issue: https://github.com/OmniSharp/omnisharp-vscode/issues/2937. We are working on updating the msbuild and add the new sdk resolvers. cc @rchande

I have the same issue on Ubuntu with all my coreapp2.2 projects. Is there an easy way to rollback the SDK update? I'm kinda stuck.

For anyone trying to fix this quickly:

$ apt-cache policy dotnet-sdk-2.2 

dotnet-sdk-2.2:
  Installed: 2.2.202-1
  Candidate: 2.2.202-1
  Version table:
... 

which is followed by the list of versions

$ sudo apt install dotnet-sdk-2.2=<your version of choice>
for me it was

$ sudo apt install dotnet-sdk-2.2=2.2.105-1

and confirm the downgrade

Thanks @leawp ; for Fedora
sudo dnf install dotnet-sdk-2.2-2.2.105-1
did the trick!

Thanks @leawp this also works for me on Mint 19.1.

That sounds great. Thanks @leawp .

Thank you, @leawp! Mint Cinnamon 19.1, here!

As a quick workaround, you can also set the MSBuildSDKsPath environment variable and point to Sdks location.

On Linux (Ubuntu 18.04 in my case) I added following to my .bashrc

export MSBuildSDKsPath ="/usr/share/dotnet/sdk/2.2.202/Sdks"

On Windows Edit System Environment Variables and add a system variable MSBuildSDKsPath and set to C:\Program Files\dotnet\sdk\2.2.202\Sdks

Fails in both Windows and Linux.

Experiencing this issue too. I installed Ubuntu 18.10 and VS Code about a month ago. This morning I updated to the latest VS Code via apt and then installed the .NET Core SDK, created a new project with dotnet new web -o MyWebApp and opened it. Then it prompted me to install the C# extension when I opened one of the C# files as expected, and it installed okay, but then gave this error in the extension output:

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: /home/matt/MyWebApp/MyWebApp.csproj

This was actually me reproducing the issue from last night, where I also experienced the issue on another Ubuntu install. Same steps - fresh .NET Core SDK and C# extension install.

My versions:

~ > code --version
1.33.0
0dd516dd412d42323fc3464531b1c715d51c4c1a
x64
~ > dotnet --version
2.2.203

Please don't set MSBuildSdksPath. Install 2.2.1xx until the version is released that can resolve 2.2.2xx. This causes unexpected issues for VS and dotnet.

Is there a way to manually install an older 2.2.1xx version on Ubuntu? I notice that the only packages that seem to be available via apt are 2.2 and 2.1. I tried going back to 2.1 but that's not working for me.

For anyone trying to fix this quickly:

$ apt-cache policy dotnet-sdk-2.2 

dotnet-sdk-2.2:
  Installed: 2.2.202-1
  Candidate: 2.2.202-1
  Version table:
... 

which is followed by the list of versions

$ sudo apt install dotnet-sdk-2.2=<your version of choice>
for me it was

$ sudo apt install dotnet-sdk-2.2=2.2.105-1

and confirm the downgrade

Thanks for the quick-fix! Works on Ubuntu 18.04.

Edit: For some reason, after applying that now when I try to dotnet run, I get:

error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.

The build failed. Please fix the build errors and run again.

Edit 2: Fixed by https://github.com/OmniSharp/omnisharp-vscode/issues/2816#issuecomment-459634725

Is there a way to manually install an older 2.2.1xx version on Ubuntu? I notice that the only packages that seem to be available via apt are 2.2 and 2.1. I tried going back to 2.1 but that's not working for me.

@welkie try the solution from this answer: https://github.com/OmniSharp/omnisharp-vscode/issues/2965#issuecomment-480262373

@broder-peters-k24 I tried that and unfortunately I feel like I did too much. I ran the apt remove command to remove the version I already had installed, and I noticed at the end it said it was able to remove it but there was a directory that wasn't empty that was left over. So then I ran:

sudo rm -rf /usr/share/dotnet

to finish the uninstall. I figured that was safe since a future install would create any directories needed. I then ran sudo apt install dotnet-sdk-2.2=2.2.105-1 to install that particular version, and it succeeded but now I don't have access to the dotnet command. which dotnet turns up nothing, and this happens:

~ > file /usr/bin/dotnet
/usr/bin/dotnet: broken symbolic link to ../share/dotnet/dotnet

I feel like I may have gotten my machine into an inconsistent state where it's unable to create the binary when I install versions of the SDK.

Hello all,

We recently did a bunch of work in omnisharp to update the msbuild and the sdk resolvers so that they work with the new sdks as well. Could you try setting "omnisharp.path": 1.32.17 and restarting omnisharp and checking if the issue persists?

Hi @akshita31

Thanks for the quick update. Sorry if I appear stupid, but not sure how to do this - I'm using the OmniSharp C# extension from within Visual Studio Code. Only versions I see available are 1.18.0 and older.

@Bob1904 open your settings.json and set the value of "omnisharp.path" to "1.32.17". As you noticed, the C# extension is currently on 1.18.0. In order to provide intellisense, it uses a component called OmniSharp that's versioned independently--that's what we want to change the version of.

@rchande @akshita31
Thanks for working with me on this. I edited settings.json as follows:
{
"workbench.iconTheme": "material-icon-theme",
"editor.tabSize": 2,
"csharp.referencesCodeLens.enabled": false,
"workbench.colorTheme": "Solarized Light",
"omnisharp.path": "1.32.17"
}

Incidentally, there was previously no "omnisharp" entry in settings.json, and the other settings are just various customizations.

When I save, I get a prompt "OmniSharp configuration has changed. Would you like to relaunch the OmniSharp server with your changes?", and I click "Restart OmniSharp".

In the Output window of VS Code, I get:

Installing OmniSharp Version = 1.32.17...
Platform: linux, x86_64, name=linuxmint, version=19.1

Downloading package 'OmniSharp for Linux (x64), Version = 1.32.17' Failed to download from https://roslynomnisharp.blob.core.windows.net/releases/1.32.17/omnisharp-linux-x64.zip. Error code '404')
Failed at stage: downloadPackage
404

@Bob1904 Could you try setting omnisharp.path: "latest" ?

@akshita31 @rchande Success on Linux Mint 19.1 ! Thank you for getting this fixed so quickly!!

Here are the steps I followed:

In the VS Code menu, go into File / Preferences / Settings.

In the "Search settings" window, type omnisharp.path

Click on "Edit in settings.json" link. Add (or edit) like this:

{
"omnisharp.path": "latest"
}

If your settings.json already had entries in it, put a comma behind the last one and add the line like this:

{
"workbench.colorTheme": "Solarized Light",
"omnisharp.path": "latest"
}

Save settings.json

You'll see a prompt: "OmniSharp configuration has changed. Would you like to relaunch the OmniSharp server with your changes?" Click the "Restart OmniSharp" button to reload it.

In the Output window you'll see updates while the latest version downloads.

Then you'll see another prompt: "Required assets to build and debug are missing from '[your project name]'. Add them?" Click Yes.

You should be in business!

I can confirm this also works on MX Linux 18.1

Note: For a completely clean machine, one that has never run VS Code or OmniSharp before, the experience may be a little different. In my case, I created a new virtual machine (VirtualBox) running Linux Mint 19.1, installed all updates, then installed .NET Core SDK 2.2.203 and VS Code 1.33.1. Then I created a new project as follows (from the command line):

dotnet new mvc -o webtest01
cd webtest01
code .

When VS Code started, I expected to get the OmniSharp prompt asking if I wanted to add required assets to the project, but didn't get that message.

Went into "Extensions" and manually added "C# for Visual Studio Code (powered by OmniSharp)", which downloaded and installed.

Then got a popup message on bottom right: "Some projects have trouble loading. Please review the output for more details. Source: C# (Extension)". _(Note that this was the starting point for my original problem report)_

Now add the omnisharp.path setting in settings.json as described earlier in this thread, then save settings.json.

Then you should get a popup message on the bottom right: "OmniSharp configuration has changed. Would you like to relaunch the OmniSharp server with your changes?" Clicked "Restart OmniSharp"

An updated OmniSharp package will download and install, which you'll see happening in the Output window.

Then you'll get the another prompt: "Required assets to build and debug are missing from '[your project name]'. Add them?" Click Yes.

Things should be working now.

Thanks for the fix - can confirm working on Ubuntu 18.04, dotnet SDK 2.2.203, with the
{
"omnisharp.path": "latest"
}

in VS Code settings.json

Is there an ETA for when the extension will work without overriding the setting?

@welkie what does ls -la /usr/bin/dotnet return to you?

➜  ~ which dotnet
/usr/bin/dotnet
➜  ~ ls -la /usr/bin/dotnet 
lrwxrwxrwx 1 root root 22 Mar 22 04:55 /usr/bin/dotnet -> ../share/dotnet/dotnet*

@welkie We don't comment on release dates, but a build is available: https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.19.0

@Bob1904 It sounds like this is resolved with our new build--I'm going to close it. Feel free to add further comments.

@rchande @akshita31 Thank you for your work on this.

@Bob1904 what was the reason? I have the same problem with my own code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mshinnie picture mshinnie  Â·  3Comments

nguillermin picture nguillermin  Â·  3Comments

gregg-miskelly picture gregg-miskelly  Â·  3Comments

olfek picture olfek  Â·  3Comments

hamhub7 picture hamhub7  Â·  3Comments