Fix sdk resolver for net6 assemblies. Using offical .NET release JSON to get runtime version #2625
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Use Microsoft.Deployment.DotNet.Releases which parses Releases Index to determine .NET runtime version matching resolved SDK specified in a
global.json
file.Using
RuntimeInformation.FrameworkDescription
to determine the runtime version seems to be not guaranteed and how it determines the runtime version is not obvious. I tried it with the following installed SDKs and runtimes:SDK version -> runtime version
6.0.100-preview.3.21202.5
->6.0.0-preview.3.21201.4
6.0.100
->6.0.0
Specifying the two SDKs in a
global.json
file, in both cases, it resolved to6.0.0-preview.3.21201.4
runtime.The release index contains DotNet releases, which include released SDKs, runtimes, and all other information. The
Microsoft.Deployment.DotNet.Releases
package is a typed wrapper around that JSON file.Credit goes to @baronfel for suggesting it. Thanks
To test different versions of SDK and how
SdkAssemblyResolver
resolves them correctly, I had to add an environment variableFAKE_SDK_RESOLVER_CUSTOM_DOTNET_PATH
to inject DotNet host installation path. Installing DotNet in GitHub actions resulted in overriding the currently used SDK6.0.100-preview.3.21202.5
since both are installed in the user directory location. And installing it in another place will not letSdkAssemblyResolver
pick it up since it looks at the user and system default installation location for DotNet. Adding multiple SDK installations in GitHub actions will solve the problem, but will make it difficult to use FAKE repository directly, since in that case, FAKE will require multiple SDK installations to exist on the machine, which is not practical.If anyone has better ways to accomplish this, please let me know.
Thanks
TODO
Feel free to open the PR and ask for help
New (API-)documentation for new features exist (Note: API-docs are enough, additional docs are in
help/markdown
)unit or integration test exists (or short reasoning why it doesn't make sense)
boy scout rule: "leave the code behind in a better state than you found it" (fix warnings, obsolete members or code-style in the places you worked in)
(if new module) the module has been linked from the "Modules" menu, edit
help/templates/template.cshtml
, linking to the API-reference is fine.(if new module) the module is in the correct namespace
(if new module) the module is added to Fake.sln (
dotnet sln Fake.sln add src/app/Fake.*/Fake.*.fsproj
)Fake 5 API guideline is honored