Figure out if and how to load hostfxr from NativeAOT code for dotnetup and installation library
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
For dotnetup and the installer library, we use hostfxr APIs to list the installed SDKs (and will probably do so for runtimes in the future). Since hostfxr is a native library, it doesn't get packaged in a single-file NativeAOT app. So we need to figure out how to handle this.
Currently, after we install a .NET SDK, we try to load hostfxr.dll from the SDK we just installed. This works for NativeAOT, but might not work if we depend on new APIs in hostfxr that aren't present in an older SDK we are installing.
We could drop the dependency on hostfxr and implement similar functionality in managed code. That would risk behavior differences.
We could also shell out to `dotnet --list-sdks` or similar commands. This would likely have more overhead.
There is an existing library that implements all three of these strategies which we might be able to take advantage of: https://github.com/ericstj/dotnetlocator
A bit of prior discussion of this can be found [here](https://github.com/dotnet/sdk/pull/51485#issuecomment-3463764701)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the current hostfxr-loading path used after SDK installation, then read the linked dotnetlocator strategies and the prior discussion in dotnet/sdk#51485. Compare loading an installed hostfxr, managed implementation, and dotnet command invocation; done means selecting and documenting an approach that accounts for NativeAOT packaging, API compatibility, and overhead.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- cli, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100