Hi!
I had a task of migrating two APIs and a Azure webjob from .NET Core 2.0 to 2.1 and found this article. After changing netcoreapp2.0 to netcoreapp2.1 I got the following issue:
NETSDK1061: The project was restored using Microsoft.NETCore.App version 2.1.3, but with current settings, version 2.1.3-servicing-26724-03 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. For more information, see https://aka.ms/dotnet-runtime-patch-selection.
According to this comment on Github the solution is to uninstall the .NET Core 2.1 SDK installed by Visual Studio and download the same version again from https://www.microsoft.com/net/download/thank-you/dotnet-sdk-2.1.401-windows-x64-installer
After doing this we got another issue in our test projects (that were also migrated):
NETSDK1061: The project was restored using Microsoft.NETCore.App version 2.1.3, 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. For more information, see https://aka.ms/dotnet-runtime-patch-selection
The solution seems to be to add
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
to the test project's csproj.
Maybe this page should be updated to include this info?
In the meantime I wrote a blog post with step by step instructions on how to fix the issue: https://jellyhive.com/activity/posts/2018/09/05/how-to-really-migrate-from-net-core-2-0-to-2-1/
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
I can confirm that it fixed the same issue for me. Thanks.
Thank you for your feedback @smatsson. @livarcocc @KathleenDollard what should I add to the migration guide from 2.0 to 2.1 in regards to these issues?
I had the same issue with SDK v2.1.403: Just uninstalling and reinstalling it from https://www.microsoft.com/net/download resolved the issue.
Can someone explain why this is happening? To me it looks more like a bug in the Visual Studio installer, so maybe that is what needs to be fixed instead of updating the migration guide.
From doing some research I found that there was a bug in Visual Studio which was fixed in 15.3,.8 however someone in that link also mentioned they had that problem.
If you still get this error it may be indicating that your previous restore operation was performed on a different version compared to what you're trying to build with. You may just need to re-restore using the same version you're building with.
@Andrew-MSFT @KathleenDollard Are you familiar with this issue? Should we add info about this in the 2.0 -> 2.1 migration doc? Please advise.
@mairaw This is not a migration issue (it should also happen for a project that was originally created targeting .NET Core 2.1). Some of this is covered in https://docs.microsoft.com/en-us/dotnet/core/deploying/runtime-patch-selection. Some of the issues that could cause this error are fixed in the 2.2 SDK, so I'd recommend using that (while still targeting .NET Core 2.1).
Thanks @dsplaisted for your input. Gotcha.
So the aka.ms link for that error message points out to https://docs.microsoft.com/en-us/dotnet/core/deploying/runtime-patch-selection.
Perhaps it's worth adding to that topic instead the recommendation of reinstalling the SDK or upgrading to 2.2 or later if you have that error message?
The reinstalling of the SDK is for the specific issue of a bad build of exactly 2.1.401 (https://github.com/dotnet/cli/issues/9897), not the general issue of runtime patch selection. It so happens that the bad build trips the same warning.
Ok @nguerrera. So just close this as product bug then?
I believe this issue is pretty much dead. A new issue can be opened if something happens again.
Most helpful comment
Thank you for your feedback @smatsson. @livarcocc @KathleenDollard what should I add to the migration guide from 2.0 to 2.1 in regards to these issues?