Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sdk resolver for net6 assemblies. Using offical .NET release JSON to get runtime version #2625

Conversation

yazeedobaid
Copy link
Collaborator

@yazeedobaid yazeedobaid commented Nov 15, 2021

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 to 6.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 variable FAKE_SDK_RESOLVER_CUSTOM_DOTNET_PATH to inject DotNet host installation path. Installing DotNet in GitHub actions resulted in overriding the currently used SDK 6.0.100-preview.3.21202.5 since both are installed in the user directory location. And installing it in another place will not let SdkAssemblyResolver 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)

    Note: Consider using the CreateProcess API which can be tested more easily, see https://github.com/fsharp/FAKE/pull/2131/files#diff-4fb4a77e110fbbe8210205dfe022389b for an example (the changes in the DotNet.Testing.NUnit module)

  • 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

@yazeedobaid yazeedobaid force-pushed the fix-sdk-resolver-for-net6 branch from aef20fc to 00d4de6 Compare November 16, 2021 09:20
@yazeedobaid yazeedobaid merged commit 27bc192 into fsprojects:release/next Jan 6, 2022
yazeedobaid added a commit that referenced this pull request Jan 6, 2022
* next release

* Fix sdk resolver for net6 assemblies. Using offical .NET release JSON to get runtime version (#2625)

* Fix sdk resolver for net6 assemblies. Using official .NET release JSON to get matching runtime version

* Update RELEASE_NOTES.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SdkAssemblyResolver fails to pick up .NET 6.0
4 participants