omnisharp-roslyn: VS 2019 Preview 16.6 not being picked over 16.5 causes issues with net5.0

In a solution I’m working on, I have a WPF project which references a library project. Both are currently targeting netcoreapp5.0 which works fine. If I change both to target net5.0 (the preferred TFM going forward), I get this error from OmniSharp:

Project '..\core\core.csproj' targets 'net5.0'. It cannot be referenced by a project that targets '.NETCoreApp,Version=v5.0'.

(Fwiw, I made absolutely sure there are no projects still using netcoreapp5.0 in the solution.)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

sorry, I thought you asked about how to use the SDK resolver that ships with dotnet SDK 🙈 you can force a custom msbuild using these settings https://github.com/OmniSharp/omnisharp-roslyn/pull/1545#issuecomment-510461836

however, 16.6 should be picked before 16.5 - it does so on my machine at least (and the sample you posted also works then), so looks like it’s non deterministic. I will check that

Using instructions at https://github.com/OmniSharp/omnisharp-roslyn/pull/1545#issuecomment-510461836, I inserted the following in %USERPROFILE%\.omnisharp\omnisharp.json to resolve my issue:

{
  "MSBuild": {
    "MSBuildOverride": {
      "MSBuildPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\MSBuild\\Current\\Bin",
      "Name": "Overridden MSBuild"
    }
  }
}

Also, a minimal installation of VS 2019 Preview with just Roslyn + MSBuild results in:

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 3 MSBuild instance(s)
            1: Visual Studio Community 2019 16.5.30011.22 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
            2: Visual Studio Community 2019 16.6.30105.148 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin"
            3: StandAlone 16.4 - "C:\Users\alex\.vscode\extensions\ms-dotnettools.csharp-1.21.18\.omnisharp\1.35.1\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2019 16.5.30011.22 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"

Can I tell OmniSharp which one to use? I’d rather not have to uninstall the stable version of VS 2019.