Skip to content

Proposal: hostfxr_get_clr_properties to get all the information needed to self-host host a clr runtime. #3290

@pauldotknopf

Description

@pauldotknopf

Currently, we can invoke hostfxr in a hosted setup, but only invoke a Program.Main.

I need to host a runtime that I control myself, using coreclrhost.h (here). To do this, I need to know all the information needed to start a runtime.

  1. The coreclr path so that I can load and invoke it.
  2. All the properties that were passed to the coreclr. This includes any runtime properties (eg, System.GC.Server), TRUSTED_PLATFORM_ASSEMBLIES, APP_PATHS, etc, etc.

There is already a hostfxr_get_native_search_directories method, but it only returns a piece of the puzzle.

I'd like to create a pull request that adds a hostfxr_get_clr_properties method. This method would return a JSON object (serialized as string) that contains all the info needed to host a coreclr runtime.

This is what I'm thinking for the returned JSON object.

{
    "coreclrPath": "/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/libcoreclr.dylib",
    "properties": {
        "TRUSTED_PLATFORM_ASSEMBLIES": "...",
        "APP_PATHS": "..."
        "NATIVE_DLL_SEARCH_DIRECTORIES": "..."
    }
}

The properties property would contain every property that is listed here.

With this information, we can self-host a .NET Core runtime with greater control on the lifetime of the runtime and what is done with the runtime.

Maybe I'm totally off base. Maybe there is another way to self-host .NET Core while utilizing deps.json and runtimeconfig.json? I'd love some input before I begin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions