From @mikeharder on June 19, 2018 2:11
Repro Steps
dotnet new console --no-restore
dotnet restore -r win-x64
dotnet build -r win-x64 --no-restore
These steps work as expected in CLI 2.1.300. However, in CLI 2.1.301 the build step fails:
C:\Temp\foo\foo.csproj : error : The project was restored using Microsoft.NETCore.App version 2.1.0, but with current settings,
version 2.1.1 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.
The error message is misleading, since the RuntimeIdentifier (-r) is set during both restore and build.
A workaround is to remove the --no-restore from the dotnet build command:
Restoring packages for C:\Temp\foo\foo.csproj...
Installing runtime.win-x64.Microsoft.NETCore.DotNetAppHost 2.1.1.
Installing runtime.win-x64.Microsoft.NETCore.DotNetHostResolver 2.1.1.
Installing runtime.win-x64.Microsoft.NETCore.DotNetHostPolicy 2.1.1.
Installing runtime.win-x64.Microsoft.NETCore.App 2.1.1.
Generating MSBuild file C:\Temp\foo\obj\foo.csproj.nuget.g.props.
Generating MSBuild file C:\Temp\foo\obj\foo.csproj.nuget.g.targets.
Restore completed in 24.89 sec for C:\Temp\foo\foo.csproj.
foo -> C:\Temp\foo\bin\Debug\netcoreapp2.1\win-x64\foo.dll
Is this a bug or by design? Is it expected that dotnet build -r runtime --no-restore should always work after dotnet restore -r runtime?
CC: @JunTaoLuo
Copied from original issue: #2344
From @mikeharder on June 19, 2018 2:11
Repro Steps
dotnet new console --no-restoredotnet restore -r win-x64dotnet build -r win-x64 --no-restoreThese steps work as expected in CLI 2.1.300. However, in CLI 2.1.301 the build step fails:
The error message is misleading, since the
RuntimeIdentifier (-r)is set during both restore and build.A workaround is to remove the
--no-restorefrom thedotnet buildcommand:Is this a bug or by design? Is it expected that
dotnet build -r runtime --no-restoreshould always work afterdotnet restore -r runtime?CC: @JunTaoLuo
Copied from original issue: #2344