我使用dotnet创建了一个示例项目,但在构建项目时出现以下错误:
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.
有什么问题?我正在使用VS 2017 build 15.7.0
解决方法
我有类似的错误消息:
The project was restored using Microsoft.NETCore.App version 2.0.7,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
我将RuntimeFrameworkVersion设置添加到.csproj文件中,它为我修复了一个问题:
<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>