0
votes

Our project is configured to use version 2.1.0 of asp.net core. However, the debugger shows that version 2.1.1 of the sdk assemblies is being loaded. For example

Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.1\System.Private.CoreLib.dll’

dotnet —version returns 2.1.300 (which equates to 2.1.0 according to [https://www.microsoft.com/net/download/dotnet-core/2.1].

The highest versioned SDK on the machine is C:\Program Files\dotnet\sdk\2.1.300.

dotnet/shared directory shows healthy looking subdirectories for 2.1.0 and 2.1.1 under Microsoft.AspNetCore.All, Microsoft.AspNetCore.App and Microsoft.NetCoreApp.

There are no interesting references to the string 2.1.1 in the project.

The project SDK is

<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0">

There are references (their purpose is not clear) to the 2.1.1 SDK in the registry. (This is the best contender I can see for an explanation together with dotnet info Host, below).

dotnet —info shows

Host (useful for support):
Version: 2.1.1
Commit: 6985b9f684

I wonder where that comes from.

Not surprisingly most of the chatter on this has recommended moving from v2.1.0 to 2.1.1. However it would be enlightening to know what is going on.

The project is on 2.1.0 for historical reasons. We are taking some liberties with some .NET Framework dependencies so changing versions is an area to beware. But before we inevitably move to 2.1.3 (or whatever the latest is) it would be good to scratch this itch.

The question is more than academic. The following sort of error shows up when modifying razor pages while the server is running. I assume/hope it is related to the above. The pages are being served directly by Kestrel.

The type 'RazorViewAttribute' exists in both 'Microsoft.AspNetCore.Mvc.Razor, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'Microsoft.AspNetCore.Mvc.Razor, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

1

1 Answers

3
votes

.NET Core applications run in one of two modes, framework-dependent or self-contained. Your application is running in framework-dependent mode which means the roll forward policy of .NET Core is lifting your app to 2.1.1 because that is the highest 2.1.* version installed. See https://docs.microsoft.com/en-us/dotnet/core/versions/selection#framework-dependent-apps-roll-forward.

Also, I recommend taking a look at this blog post which goes into more detail about the relationship between the PackageReference to Microsoft.AspNetCore.App and the shared framework it runs on. https://natemcmaster.com/blog/2018/08/29/netcore-primitives-2/