Build error of ASP.NET Core - “…current settings, version 2.1.0-preview3-26411-06 would be used instead”

后端 未结 10 1412
南方客
南方客 2021-02-07 20:18

I\'ve created a sample project using dotnet, but I get the following error when building the project:

error : The project was restored using Mic

10条回答
  •  逝去的感伤
    2021-02-07 20:51

    Just because you have the latest SDK installed doesn't mean you have the latest runtime installed. I'll never quite understand that.

    Run dotnet --info.

    I got the following (only the latest installed versions are shown here).

     .NET Core SDKs installed:
       2.1.300 [C:\Program Files\dotnet\sdk]
    
     .NET Core runtimes installed:d\Microsoft.NETCore.App]
      Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    
    • So I installed 2.1.1 runtime, and now dotnet --info gives me 2.1.1 as well.

    • Oh and 2.1.3 actually is 2.1.1, but they had to increment it for some reason I don't fully understand about or care about.

    • I restarted Visual Studio, because it never seems to be able to keep versions in sync

    • I added the following to PropertyGroup in my .csproj file (unload project + edit)

      netcoreapp2.1 2.1.1

    Now I thought we didn't need to specify this this any more, and this .csproj file was just created brand new today and it didn't have a runtime version at all. Whatever we're supposed to be doing, this worked for me. I also found this massive thread about versioning with 2.1.1 which I skimmed over, but it seems there are complications with point releases right now, so maybe this specific version is necessary.


    I ended up here because of this error:

    error : The project was restored using Microsoft.NETCore.App version 2.1.1, but with current settings, version 2.1.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.

    Adding RuntimeFrameworkVersion was the specific fix for that that worked.

    Unfortunately there isn't any linked article for this error message, which would be helpful.

提交回复
热议问题