Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

error : The project was restored using Microsoft.NETCore.App version 2.1.0-rc1, but with current settings, version 2.1.0-preview3-26411-06 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.

What's the problem? I'm using Visual Studio 2017 build 15.7.0.

like image 300
Majid Majed Avatar asked May 07 '18 21:05

Majid Majed


2 Answers

It seems Visual Studio is using different .NET Core versions for restore/build/publish.

To resolve this issue, you could add TargetLatestRuntimePatch attribute in the .csproj file:

<PropertyGroup>
   <TargetFramework>netcoreapp2.0</TargetFramework>
   <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>

For details, please see this page.

like image 166
Dmitry Kutetsky Avatar answered Oct 08 '22 13:10

Dmitry Kutetsky


I had a similar error message:

The project was restored using Microsoft.NETCore.App version 2.0.7, but with current settings, version 2.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

I added the RuntimeFrameworkVersion setting to the .csproj file, and it fixed an issue for me:

<PropertyGroup>
   <TargetFramework>netcoreapp2.0</TargetFramework>
   <RuntimeFrameworkVersion>2.0.7</RuntimeFrameworkVersion><!--here is the fix-->
</PropertyGroup>

<ItemGroup>
   <PackageReference Update="Microsoft.NETCore.App" Version="2.0.7" />
</ItemGroup>
like image 24
Keymatic Avatar answered Oct 08 '22 13:10

Keymatic