I found some interesting articles about the difficulties of .NET Core SDK/runtime/tooling versioning, for example:
However I still don't really know how to deal with all of this in practice:
- Given a project with a number of .Net Core dependencies. How can I determine which version of the runtime needs to be available on the end-users machine?
- Does the runtime version need to match exactly, or can the runtime installed on the end-users machine be newer than the required version?
- Let's say I want to stick to some LTS version of the runtime. How can I determine the version of the packages I need to reference? How can I make sure that no newer packages are referenced?
Oh, and there is one more:
- Once I know which runtime version is required on the end-users machine, how can I determine (programmatically) if that version of the runtime (or a newer, backwards compatible one) is available?
First, let's look at what happens when a portable .NET Core application is run via
dotnet yourapp.dll
:dotnet.exe
on windows) loads a version of the host framework resolver (hostfxr
) from a folder beneathhost\fxr\
next todotnet.exe
.yourapp.runtimeconfig.json
(or a different file if configured when usingdotnet exec
) to find out which framework you are targeting. This extracts a framework name (Microsoft.NETCore.App
) and a version (e.g.1.1.0
).shared\Microsoft.NETCore.App
folder (based on the framework name) for available versions.yourapp.runtimeconfig.json
it determines which version to use. Or it may decide to error out and complain that the required version is not available.