I want to migrate my repository form .NET5 to .NET6. As there are many projects, the plan is to do it in multiple steps. So it's an intended intermediate step to have some of the projects targeting .NET5 while some other set to .NET6.
I use a personal NuGet feed and the official nuget.org
is disabled.
As the first step, I updated global.json
{
"sdk": {
"version": "6.0.201",
"rollForward": "disable"
}
}
which previously used to target version 5.0.201
.
I made sure 6.0.201
is installed on my machine by using dotnet --list-sdks
╰─ dotnet --list-sdks
5.0.102 [C:\Program Files\dotnet\sdk]
5.0.201 [C:\Program Files\dotnet\sdk]
6.0.201 [C:\Program Files\dotnet\sdk]
6.0.300 [C:\Program Files\dotnet\sdk]
Then I chose a subset of the projects contained in the repository and changed
<TargetFramework>net5.0-windows</TargetFramework>
to
<TargetFramework>net6.0-windows</TargetFramework>
Everything compiles without a problem. Not even a single warning.
However, Team City machine can't build the repo. I'm getting the following error for all the net5.0
projects (so: the not migrated ones)
NU1101: Unable to find package Microsoft.NETCore.App.Host.win-x64. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, MyLocalNuGetCache
I've searched through my machine, but it doesn't contain the package Microsoft.NETCore.App.Host.win-x64
. Despite this fact everything builds nicely.
Also, running dotnet --list-sdks
on my TC machine proves that 6.0.201
is installed:
╰─ dotnet --list-sdks
5.0.102 [C:\Program Files\dotnet\sdk]
5.0.201 [C:\Program Files\dotnet\sdk]
6.0.201 [C:\Program Files\dotnet\sdk]
Microsoft.NETCore.App.Host.win-x64
needed for and how can I find it on my machine?After a few days of debugging this I've gone down to the root of the problem.
To get explanation about the Microsoft.NETCore.App.Host.win-x64
package see my other post.
As there's no way to specify multiple versions of SDKs in global.json
, I wrongfully assumed that SDK 6.0.201 contains also a set of system libraries for .NET5. My not-yet-migrated projects started complaining at missing 5.0.15 packages (e.g. EF Core), so I downloaded them and placed in my personal feed.
The reason for MSBuild to pick up 5.0.15 was that that was the latest .NET SDK installed on my machine.
However, the corresponding .NET SDK (in this case: 5.0.406) was not installed on my TC machine.
That's a quick summary.
I'm going to need both .NET6 and .NET5 apps in my repo - at least for some time. The fact that I can't pin SDK version for both targets in global.json
is very misleading. It's already caused a lot of problems and I expect more dragons to show up in the future.