Skip to content

Provide a hostfxr API for resolving runtime frameworks #99027

@elinor-fung

Description

@elinor-fung

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:

struct hostfxr_framework_result
{
    size_t size;
    const char_t* name;
    const char_t* requested_version;
    const char_t* resolved_version;
    const char_t* resolved_path;
};

struct hostfxr_resolve_frameworks_result
{
    size_t size;

    size_t resolved_count;
    const struct framework_result* resolved_frameworks;

    size_t unresolved_count;
    const struct framework_result* unresolved_frameworks;
};

typedef void (*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 callback
int32_t hostfxr_resolve_frameworks_for_runtime_config(
    const char_t* runtime_config_path,
    /*opt*/ const hostfxr_initialize_parameters* parameters,
    /*opt*/ hostfxr_resolve_frameworks_result_fn callback,
    /*opt*/ void* result_context);

Related:

cc @agocke @JL03-Yue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions