You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide a hostfxr API for resolving runtime frameworks #99027
There is currently no way to run the host's runtime framework resolution algorithm in an isolated manner. This can be helpful for doing things like determining whether an application would be able to run on the current environment.
We could add a hostfxr_resolve_runtime_frameworks that acts as a parallel to hostfxr_resolve_sdk. Something like:
structhostfxr_framework_result
{
size_t size;
constchar_t* name;
constchar_t* requested_version;
constchar_t* resolved_version;
constchar_t* resolved_path;
};
structhostfxr_resolve_frameworks_result
{
size_t size;
size_t resolved_count;
conststructframework_result* resolved_frameworks;
size_t unresolved_count;
conststructframework_result* unresolved_frameworks;
};
typedefvoid (*hostfxr_resolve_frameworks_result_fn)(
const hostfxr_resolve_frameworks_result* result,
void* result_context);
// runtime_config_path : path to the runtime config file// parameters : additional parameters for initialization// if null or dotnet_root is null, the root corresponding to the running hostfxr is used// callback : invoked with the result of the resolution// result_context : additional context passed to the callbackint32_thostfxr_resolve_frameworks_for_runtime_config(
constchar_t* runtime_config_path,
/*opt*/const hostfxr_initialize_parameters* parameters,
/*opt*/ hostfxr_resolve_frameworks_result_fn callback,
/*opt*/void* result_context);
For future considerations - I vaguely remember scenarios where this would help if the input was not a file but some in-memory data structure describing the required dependencies. I think WiX installers wanted something like that - workaround is to write a temp config file to disk, but that's obviously not ideal.
Especially having an API that operates on the installation/layout that the hostfxr is present in when unspecified instead of the global installation would be very useful.
For future considerations - I vaguely remember scenarios where this would help if the input was not a file but some in-memory data structure describing the required dependencies.
Maybe hostfxr_resolve_runtime_frameworks -> hostfxr_resolve_frameworks_for_runtime_config for this one then. So we don't have to figure out some horrible name for an in-memory data structure version.
Especially having an API that operates on the installation/layout that the hostfxr is present in when unspecified instead of the global installation would be very useful.
That is what the hostfxr_initialize_* functions do. I think it would be reasonable for this one to do the same. For the functions for getting environment information like hostfxr_get_dotnet_environment_info and hostfxr_get_available_sdks, I could see having some sentinel value that could be passed as dotnet_root to indicate that the running hostfxr should be used.
Activity
JL03-Yue commentedon Feb 28, 2024
@elinor-fung Thank you so much for putting up the issue. I would love to keep this updated and keep following up with the issue.
vitek-karas commentedon Feb 28, 2024
Looks great to me.
For future considerations - I vaguely remember scenarios where this would help if the input was not a file but some in-memory data structure describing the required dependencies. I think WiX installers wanted something like that - workaround is to write a temp config file to disk, but that's obviously not ideal.
jkoritzinsky commentedon Feb 28, 2024
I had a scenario where I don't have a runtimeconfig file on disk and would like to use this API. I'm currently using
hostfxr_get_dotnet_environment_infoto get something that works. (code is at https://github.com/AaronRobinsonMSFT/DNMD/blob/master/test/regpal/pal.cpp#L154).Especially having an API that operates on the installation/layout that the hostfxr is present in when unspecified instead of the global installation would be very useful.
elinor-fung commentedon Feb 29, 2024
Maybe
hostfxr_resolve_runtime_frameworks->hostfxr_resolve_frameworks_for_runtime_configfor this one then. So we don't have to figure out some horrible name for an in-memory data structure version.That is what the
hostfxr_initialize_*functions do. I think it would be reasonable for this one to do the same. For the functions for getting environment information likehostfxr_get_dotnet_environment_infoandhostfxr_get_available_sdks, I could see having some sentinel value that could be passed asdotnet_rootto indicate that the running hostfxr should be used.Cleanup of `fx_resolver_t` and tests in `NativeHostApis` (#100542)
Cleanup of `fx_resolver_t` and tests in `NativeHostApis` (dotnet#100542)
Cleanup of `fx_resolver_t` and tests in `NativeHostApis` (dotnet#100542)