omnisharp-roslyn: OmniSharp.MSBuild.Discovery.MSBuildLocator picks wrong MSBuild path

From @pquiring on December 25, 2017 17:27

Environment data

dotnet --info output: .NET Command Line Tools (2.1.3)

Product Information: Version: 2.1.3 Commit SHA-1 hash: a0ca411ca5

Runtime Environment: OS Name: Windows OS Version: 10.0.16299 OS Platform: Windows RID: win10-x64 Base Path: C:\Apps\dotnet\sdk\2.1.3\

Microsoft .NET Core Shared Framework Host

Version : 2.0.4 Build : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff

VS Code version: 1.19.1

C# Extension version: 1.13.1

Steps to reproduce

Install .Net Core standalone Install VS Code Install VS Build Tools with VC++ only (not .NET component) or Install VS IDE with VC++ only (not .NET component) Open .csproj in VS Code.

Expected behavior

OmniSharp runs

Actual behavior

OmniSharp tries to use MSBuild from VC++ and fails.

Starting OmniSharp server at 12/25/2017, 12:02:45 PM
    Target: c:\files\workspace\qt\apps\passwords

OmniSharp server started
    Path: C:\Users\User\.vscode\extensions\ms-vscode.csharp-1.14.0-beta2\.omnisharp\OmniSharp.exe
    PID: 9980

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Build Tools 2017 15.5.27130.2010 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\User\.vscode\extensions\ms-vscode.csharp-1.14.0-beta2\.omnisharp\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Build Tools 2017 15.5.27130.2010 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\files\workspace\qt\apps\passwords'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\files\workspace\qt\apps\passwords
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\files\workspace\qt\apps\passwords'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\files\workspace\qt\apps\passwords\passwords.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\files\workspace\qt\apps\passwords'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Stdio.Host
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Stdio.Host
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\files\workspace\qt\apps\passwords' on host 1332.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\files\workspace\qt\apps\passwords\passwords.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
        The "GetReferenceNearestTargetFrameworkTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" directory.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\files\workspace\qt\apps\passwords\passwords.csproj'.
c:\files\workspace\qt\apps\passwords\passwords.csproj


If I install .NET in VS Build Tools it works.

How can I force OmniSharp to ignore MSbuild environments that do NOT have .NET included?

Thanks.

Copied from original issue: OmniSharp/omnisharp-vscode#1941

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 12
  • Comments: 62 (13 by maintainers)

Most upvoted comments

Work around: Rename “C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild” to MSBuild.disabled or Rename “C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild” to MSBuild.disabled

@UncleInf @johnnyreilly @boris-741 @LuizPelegrini @zvinless I’m sorry you’re running into issues. From what’s reported, it sounds like there’s an issue with the “standalone” MSBuild shipped with OmniSharp on Windows. There are a couple of workarounds you can do while we investigate:

Thanks for your patience–we are actively investigating.

I ran into this problem in a .NET Core project, the initial symptoms were many compile errors that boiled down to You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. It turned out that instead of the built-in MSBuild, OmniSharp was selecting the one from VS2017.

With VS 2017

OmniSharp log:

Starting OmniSharp server at 6/17/2019, 1:27:52 PM
    Target: c:\Users\jrend\repos\internal\ffs

OmniSharp server started.
    Path: C:\Users\jrend\.vscode\extensions\ms-vscode.csharp-1.20.0\.omnisharp\1.32.20\OmniSharp.exe
    PID: 13120

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Community 2017 15.9.28307.718 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\jrend\.vscode\extensions\ms-vscode.csharp-1.20.0\.omnisharp\1.32.20\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2017 15.9.28307.718 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"

Result:

Error reported in VS Code: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. (CS0012) (and 400+ other errors) Compilation: works as expected. Seems like the build task uses the extension’s MSBuild, but OmniSharp uses the VS2017 one.

After installing VS 2019

OmniSharp log:

Starting OmniSharp server at 6/17/2019, 1:53:48 PM
    Target: c:\Users\jrend\repos\internal\ffs

OmniSharp server started.
    Path: C:\Users\jrend\.vscode\extensions\ms-vscode.csharp-1.20.0\.omnisharp\1.32.20\OmniSharp.exe
    PID: 17352

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 3 MSBuild instance(s)
            1: Visual Studio Community 2017 15.9.28307.718 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
            2: Visual Studio Community 2019 16.1.29009.5 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
            3: StandAlone 15.0 - "C:\Users\jrend\.vscode\extensions\ms-vscode.csharp-1.20.0\.omnisharp\1.32.20\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2019 16.1.29009.5 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"

Result:

It works.


Adding $USERPROFILE\.omnisharp\omnisharp.json with specific MSBuildSdksPath as mentioned in https://github.com/OmniSharp/omnisharp-vscode/issues/1727 had no effect – the VS2019 one still got selected. Adding omnisharp.json in the project directory also didn’t have an effect.

I was a curious about this and tried to dig a bit to find out why this happens or what other options are there to control the choice of MSBuild to be used. Seems like it’s on purpose that the builtin MSBuild is sorted lower than VS ones (source), which for me seems strange since the current builtin one is MSBuild 16, while VS2017 is MSBuild 15.

Upon seeing this method I see now that it’s also not a coincidence that VS 2019 / MSBuild 16 was picked over MSBuild 15; seems like the “pick 16 over 15” rule wouldn’t apply to the builtin MSBuild, though, since it gets a lower score. That is very unfortunate, seems like there is a dependency on MSBuild 16 but MSBuild 15 can be picked if you happen not to have a newer VS, which in my case caused some lost time in debugging all of this.

I’ve had this problem in OSX. Went to user settings in VS Code and disabled “Global Mono”. It loads theStandAlone 15.0 now.

Same problem in vscode today after omnisharp update

👍 would like a real workaround. I just uninstalled the MS Build Tools for now.

Work around: Rename “C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild” to MSBuild.disabled or Rename “C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild” to MSBuild.disabled

after struggling for couple of days finally this solution worked out for me. Thank you

unfortunately the embedded msbuild is not functionally equivalent to that what ships with mono or VS itself, this is particularly relevant for example for unity projects or projects with custom SDK, and should normally be the last resort fallback.

just like we eliminated VS2017 from being discovered though, I can imagine we will soon eliminate VS2019 <16.3 too which will make this issue go away.

That said, I don’t think it’s a terrible assumption that if you have VS2019 installed and want to do .NET Core 3.1 on your machine, your VS2019 will be updated accordingly.

Date is now almost 2020 and we still are facing same issue.for sake of god tell us how to specify msbuild path manually. MSBuildSdksPath is not working for me either.

I have the same problem. Here’s the output of the build locator:

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Community 2019 16.2.29230.47 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
            2: StandAlone 16.3 - "C:\Users\Honza\.vscode\extensions\ms-vscode.csharp-1.21.7\.omnisharp\1.34.7\.msbuild\Current\Bin"

I’ve got .NET Core 3.0 SDK installed as well as multiple 2.x versions and VS 2019. The VS 2019 MSBuild probably gets the priority and as a result, I’m getting the following error:

[fail]: OmniSharp.MSBuild.ProjectLoader
        The current .NET SDK does not support targeting .NET Core 3.0.  Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\Honza\dev\learn\netcorereact\reactivities\API\API.csproj'.
c:\Users\Honza\dev\learn\netcorereact\reactivities\API\API.csproj
C:\Program Files\dotnet\sdk\2.2.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): Error: The current .NET SDK does not support targeting .NET Core 3.0.  Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0.

Update: Upgrading VS to the latest (16.3.x) version fixes the issue.

I’m having the same issue:

dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   2.2.105
 Commit:    7cecb35b92

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.105\

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

.NET Core SDKs installed:
  2.2.105 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

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

Startup log:

        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Build Tools 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\alex\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Build Tools 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\dev\test'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
        Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\dev\test'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\dev\test\firstSite\firstSite.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\dev\test'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\dev\test' on host 19476.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\dev\test\firstSite\firstSite.csproj
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\dev\test\firstSite\firstSite.csproj'.
c:\dev\test\firstSite\firstSite.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.  c:\dev\test\firstSite\firstSite.csproj
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, Boolean throwOnFileNotExistsError)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
   at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
   at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath)
   at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath)
   at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectLoader loader)
   at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader)

[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: c:\dev\test\firstSite\firstSite.csproj

What is the recommended work around?

Having the same issue, hiding the VS MSBuild works but I’m getting alarming errors in omni logs. And I’m getting wrong c# version errors on c# 8 syntax. I tried <LangVersion>8.0</LangVersion> and <LangVersion>latest</LangVersion>, doesn’t seem to help. omnisharp.log

Edit: Once I installed VS 2019 Preview, omni picked up that MSBuild (16) and now everything works dandy. For now that’s the msbuild to use, and I think it’s only publicly available with 2019 preview, unless you have a sneaky insiders 2019 build tools install.

Another data point… I just upgraded dotnet using chocolatey (was 2.1.101 or something, now 2.1.403). Then created a new project:

dotnet new console --name New.Project
dotnet new sln --name New.Project
dotnet sln add .\New.Project\New.Project.csproj
dotnet build
code .

Which results in this OUTPUT:

Starting OmniSharp server at 10/13/2018, 1:52:37 PM
    Target: c:\Users\lucas\git\new-project\New.Project.sln

OmniSharp server started.
    Path: C:\Users\lucas\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\OmniSharp.exe
    PID: 9056

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Build Tools 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\lucas\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Build Tools 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\lucas\git\new-project'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
        Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in 'c:\Users\lucas\git\new-project\New.Project.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\lucas\git\new-project\New.Project\New.Project.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\lucas\git\new-project'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\lucas\git\new-project' on host 16340.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\lucas\git\new-project\New.Project\New.Project.csproj
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\lucas\git\new-project\New.Project\New.Project.csproj'.
c:\Users\lucas\git\new-project\New.Project\New.Project.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.  c:\Users\lucas\git\new-project\New.Project\New.Project.csproj
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, Boolean throwOnFileNotExistsError)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
   at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
   at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath)
   at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath)
   at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectLoader loader)
   at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader)

[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: c:\Users\lucas\git\new-project\New.Project\New.Project.csproj

My dotnet --info output is:

PS C:\Users\lucas\git\new-project> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.403
 Commit:    04e15494b6

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.403\

Host (useful for support):
  Version: 2.1.5
  Commit:  290303f510

.NET Core SDKs installed:
  2.1.105 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

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

My guess is that it has something to do with this:

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Build Tools 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\lucas\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\msbuild\15.0\Bin"

Which I would imagine might have dotnet mentioned (as in dotnet msbuild). My dotnet install is at:

PS C:\Users\lucas\git\new-project> get-command dotnet

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     dotnet.exe                                         2.1.269... C:\Program Files\dotnet\dotnet.exe

I just tried upgrading to the 1.17.0 (prerelease) just to see if it changed anything… It didn’t still having this issue.

Also tried global settings:

PS C:\Users\lucas\git\new-project> Get-Content $env:USERPROFILE/.omnisharp/omnisharp.json
{
    "MsBuild": {
        "MSBuildSDKsPath": "C:/Program Files/dotnet/sdk/2.1.403/Sdks"
    }
}

But had the same outcome.

Well, my final solution is to remove Microsoft build tools altogether leaving only the dotnetcore-sdk. Not sure why my build tools didn’t work but i don’t need em anyway…

FYI, instructions for installing releases of C# for VS Code are here: https://github.com/OmniSharp/omnisharp-vscode/wiki/Installing-Beta-Releases.

@UncleInf @johnnyreilly @boris-741 @LuizPelegrini @zvinless I’m sorry you’re running into issues. From what’s reported, it sounds like there’s an issue with the “standalone” MSBuild shipped with OmniSharp on Windows. There are a couple of workarounds you can do while we investigate:

Thanks for your patience–we are actively investigating.

Downgrading omnisharp to 1.15 and disabling extension auto update worked for me! Thanks for the support @rchande !

This started happening for me after the 1.16.0 update, too:

  • VSCode 1.27.1
  • macOS High Sierra 10.13.16
  • Mono 5.14.0.177 (Homebrew, also happens if I use Mono MDK instead)
  • .NET Core SDK 2.1.401