Omnisharp-vscode: NETSDK1061 version mismatch error after update

Created on 12 Aug 2020  路  9Comments  路  Source: OmniSharp/omnisharp-vscode

I recently upgraded my Ubuntu packages (I saw some dotnet packages were updated during this), and now when I start VS Code I have a OmniSharp error:

[fail]: OmniSharp.MSBuild.ProjectLoader
        NETSDK1061: The project was restored using Microsoft.NETCore.App version 1.0.5, but with current settings, version 3.0.0 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection.

I can still build & run normally, both from IDE and command line.

I have also tried a restore from command line, and it did not seem to fix the issue.

I don't think I was having this issue before updating the system packages.

Environment data

.NET Core SDK (reflecting any global.json):
 Version:   3.1.401
 Commit:    39d17847db

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.401/

Host (useful for support):
  Version: 3.1.7
  Commit:  fcfdef8d6b

.NET Core SDKs installed:
  2.1.809 [/usr/share/dotnet/sdk]
  3.1.401 [/usr/share/dotnet/sdk]

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

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

VS Code version: 1.47.3
C# Extension version: 1.22.1

OmniSharp log

Starting OmniSharp server at 8/11/2020, 7:22:27 PM
    Target: /project/hatch

OmniSharp server started.
    Path: /home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/run
    PID: 16818

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on ubuntu 18.4 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.4 - "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.4 - "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/.msbuild/Current/Bin"
            CscToolExe = csc.exe
            MSBuildToolsPath = /home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/.msbuild/Current/Bin
            CscToolPath = /home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/.msbuild/Current/Bin/Roslyn
            BypassFrameworkInstallChecks = true
            MSBuildExtensionsPath = /home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/project/hatch'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in '/project/hatch'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/project/hatch/hatch.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/project/hatch'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /project/hatch/hatch.csproj
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/project/hatch' on host 16060.
[fail]: OmniSharp.MSBuild.ProjectLoader
        NETSDK1061: The project was restored using Microsoft.NETCore.App version 1.0.5, but with current settings, version 3.0.0 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/project/hatch/hatch.csproj'.
/project/hatch/hatch.csproj
/project/hatch/hatch.csproj(0,0): Error: NETSDK1061: The project was restored using Microsoft.NETCore.App version 1.0.5, but with current settings, version 3.0.0 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection.

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

Most helpful comment

@pyrrho Issues with using the latest .NET Core SDK with our included Mono should be resolved in this pre-release - https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.23.0

All 9 comments

@sky-lake hmm. It sounds like the project.assets.json file may be stale. If you run dotnet restore against your project, does it load properly the next time it is opened?

Hello!

I just tried deleting the whole obj folder of both my exe and library project. Then I tried executing dotnet restore for both in terminal. When I load up VS code, I still get the error. I don't get the error if from terminal I do dotnet build or dotnet publish

EDIT: Also, here is a possibly relevant portion from my project assets file?

"downloadDependencies": [
          {
            "name": "Microsoft.AspNetCore.App.Ref",
            "version": "[3.0.1, 3.0.1]"
          },
          {
            "name": "Microsoft.NETCore.App.Host.linux-x64",
            "version": "[3.0.3, 3.0.3]"
          },
          {
            "name": "Microsoft.NETCore.App.Ref",
            "version": "[3.0.0, 3.0.0]"
          }

@sky-lake It seems you are running into some version of https://github.com/dotnet/sdk/issues/2682

Can you share your project file?

Interesting! Here is my exe project file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
   <DefineConstants Condition="'$(SET_PRIVBUILD)'=='true'">$(DefineConstants);PRIVBUILD</DefineConstants>
   <DefineConstants Condition="'$(SET_LOCALGAMETEXTPRIVATE)'=='true'">$(DefineConstants);LOCALGAMETEXTPRIVATE</DefineConstants>
  </PropertyGroup>

  <ItemGroup>
    <Compile Update="**\*.xaml.cs">
      <DependentUpon>%(Filename)</DependentUpon>
    </Compile>
    <AvaloniaResource Include="**\*.xaml">
      <SubType>Designer</SubType>
    </AvaloniaResource>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Avalonia" Version="0.9.0" />
    <PackageReference Include="Avalonia.Desktop" Version="0.9.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\core\core.csproj" />
  </ItemGroup>
</Project>

Here is my lib project file (core.csproj):

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <OutputType>Library</OutputType>
    <DefineConstants Condition="'$(SET_PRIVBUILD)'=='true'">$(DefineConstants);PRIVBUILD</DefineConstants>
    <DefineConstants Condition="'$(SET_LOCALGAMETEXTPRIVATE)'=='true'">$(DefineConstants);LOCALGAMETEXTPRIVATE</DefineConstants>
  </PropertyGroup>

   <!-- Embedded method:
  <ItemGroup>
   <Content Remove="GameText.xml" />
   <Content Remove="GameTextPrivate.xml" />
  </ItemGroup>
  <ItemGroup>
   <EmbeddedResource Include="GameText.xml" />
   <EmbeddedResource Include="GameTextPrivate.xml" />
  </ItemGroup>
  -->

  <ItemGroup>
   <Content Include="GameText.xml" />
   <Content Include="GameTextPrivate.xml" />  <!-- TODO: Don't include on public build, if it matters.-->
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
  </ItemGroup>

</Project>

This is my first dotnet core project, so please forgive any newbie mistakes 馃檹

Update: I tried this from the other thread: <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> But it had no effect.

One other solution from that thread was removing old dotnet installs. I did this, and now I get a Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found. during VS code startup.

I think I need to somehow point omnisharp to the new dotnet 3.1 on my system as it's referencing an older version (which is now uninstalled)

I did try to update my TargetFramework to netcoreapp3.1 on both projects, but it still is getting that error.

Update 2: I thought maybe the version of omnisharp was too old to recognize the new netcore 3.1, so I tried updating it by including "omnisharp.path": "latest" in my settings.json. If I do this, I get a different error:

Starting OmniSharp server at 8/12/2020, 7:36:56 PM
    Target: /project/hatch

OmniSharp server started.
    Path: /home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/run
    PID: 17508

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on ubuntu 18.4 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.8.0 - "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin"
            CscToolExe = csc.exe
            MSBuildToolsPath = /home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin
            CscToolPath = /home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Roslyn
            BypassFrameworkInstallChecks = true
            MSBuildExtensionsPath = /home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/project/hatch'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in '/project/hatch'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/project/hatch/hatch.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/project/hatch'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/project/hatch' on host 17283.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /project/hatch/hatch.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
        "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.Xaml.targets" cannot be imported again. It was already imported at "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets (6156,3)". This is most likely a build authoring error. This subsequent import will be ignored. [/project/core/core.csproj]
[warn]: OmniSharp.MSBuild.ProjectLoader
        "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.WorkflowBuildExtensions.targets" cannot be imported again. It was already imported at "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets (6160,3)". This is most likely a build authoring error. This subsequent import will be ignored. [/project/core/core.csproj]
[warn]: OmniSharp.MSBuild.ProjectLoader
        "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.ServiceModel.targets" cannot be imported again. It was already imported at "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.CSharp.CurrentVersion.targets (343,5)". This is most likely a build authoring error. This subsequent import will be ignored. [/project/core/core.csproj]
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file '/project/hatch/hatch.csproj'.
/project/hatch/hatch.csproj
/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.Xaml.targets(19,4): Error: "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.Xaml.targets" cannot be imported again. It was already imported at "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets (6156,3)". This is most likely a build authoring error. This subsequent import will be ignored. [/project/core/core.csproj]
/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.WorkflowBuildExtensions.targets(25,4): Error: "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.WorkflowBuildExtensions.targets" cannot be imported again. It was already imported at "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets (6160,3)". This is most likely a build authoring error. This subsequent import will be ignored. [/project/core/core.csproj]
/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.ServiceModel.targets(12,4): Error: "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.ServiceModel.targets" cannot be imported again. It was already imported at "/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.36.1/omnisharp/.msbuild/Current/Bin/Microsoft.CSharp.CurrentVersion.targets (343,5)". This is most likely a build authoring error. This subsequent import will be ignored. [/project/core/core.csproj]

[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/project/hatch/hatch.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: hatch
[info]: OmniSharp.MSBuild.ProjectManager
        Found referenced project outside root directory: /project/core/core.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/project/core/core.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/project/core/core.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /project/core/core.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file '/project/core/core.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: core

Had the same issue. Aparently the sdk was working just fine, since I could build my projects via CLI while vscode couldn't resolve my dependencies.

Had to rollback the sdk version and set it in the project's gloabl.json file.

1 - Download past release https://dotnet.microsoft.com/download/dotnet-core/3.1
2 - Move the contents from the decompressed folder /dotnet/sdk/3.1.107/ to /usr/share/dotnet/sdk/ (Ubuntu)
3 - Set previous version to global.json file:
{ "sdk": { "version": "3.1.107" } }

I think I'm having an issue similar to @michellamin and @sky-lake. I upgraded from 3.1.300 to 3.1.401 and vscode began showing numerous errors in code that don't prevent the CLI from correctly building and testing the project. (The errors are somewhat nonsensical; The type 'Enum' is defined in an assembly that is not referenced.) Looking through the logs, I saw the Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found error, which is how I wound up here.

Downgrading to 3.1.302 seems to "fix" the omnisharp extension, in that the spurious errors are no longer generated.

Here's the interesting part. The Microsoft.Build.Exceptions.InvalidProjectFileException: error is still emitted in vscode's OmniSharp logs when using 3.1.302.

Perhaps Microsoft has been playing with its package layout, moved the SDK a few version back, and just recently moved the System, System.Void, etc. packages into that misplaced SDK?

@pyrrho Issues with using the latest .NET Core SDK with our included Mono should be resolved in this pre-release - https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.23.0

Can confirm the omnisharp that VS Code pulls via 'latest' appears to have fixed this issue as of yesterday
/home/sky/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.1-beta.2/run

fixed in 1.23.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZeldaZocker picture ZeldaZocker  路  3Comments

kiminuo picture kiminuo  路  3Comments

olfek picture olfek  路  3Comments

IdeoG picture IdeoG  路  3Comments

jrmcdona picture jrmcdona  路  3Comments