Search code examples
.net-corerider.net-core-3.0

Upgrading to .NET Core 3 in project that also uses netstandard2.1 is not building in Rider


I'm running on a macOS and the project I'm working on just upgraded from .NET Core 2 to .NET Core 3. The problem is that I can no longer build my project in Rider. If I try to build it in the terminal using dotnet build, the build succeeds. In my project, there are some subprojects that use netstandard2, but this should not be a problem (as its working in the terminal). I'm getting the following error message:

Project1 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Project2 supports: netstandard2.1 (.NETStandard,Version=v2.1)

I have tried to add a global.json file which specifies I'm using version 3 of .NET Core, but it didn't help.

If I'm running dotnet build once in the terminal, then the new build of Rider will succeed. So things are working, but it is just annoying to always build in the terminal first.

The output of dotnet --info: dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.0.100/

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  2.2.300 [/usr/local/share/dotnet/sdk]
  2.2.401 [/usr/local/share/dotnet/sdk]
  2.2.402 [/usr/local/share/dotnet/sdk]
  3.0.100 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

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

Solution

  • I found that the issue was in Rider. The workaround is to change PackageReference Restore Engine (in File > Settings > Build, Execution, Deployment > NuGet) to MSBuild.

    Screenshot of Rider

    The issue will be fixed in a later version of Rider, so it is recommended to switch back to Embedded after the version is relased. The difference between MSBuild and Embedded:

    MSBuild just calls external MSBuild task; Embedded directly calls NuGet API inside Rider process. Embedded should work much faster and it provides additional logs which can be useful when restore fails

    The reason for the issue:

    [...] because Rider 2019.2 EAP2 still used NuGet 4.9 internally; this version doesn't have proper support of .NET Core 3.0 / .NET Standard 2.1. In Rider 2019.2 RTM, we are going to upgrade the internal version of NuGet up to 5.1.

    Source for quotes and screenshot: https://youtrack.jetbrains.com/issue/RIDER-29888