Skip to content

Commit 911640b

Browse files
Add better description of what to pass to hostfxr_initialize_for_dotnet_command_line (#53678)
Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent b0b317e commit 911640b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

docs/design/features/native-hosting.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ int hostfxr_initialize_for_dotnet_command_line(
235235

236236
Initializes the hosting components for running a managed application.
237237
The command line is parsed to determine the app path. The app path will be used to locate the `.runtimeconfig.json` and the `.deps.json` which will be used to load the application and its dependent frameworks.
238-
* `argc` and `argv` - the command line for running a managed application. These represent the arguments which would have been passed to the muxer if the app was being run from the command line.
238+
* `argc` and `argv` - the command line for running a managed application. These represent the arguments which would have been passed to the muxer if the app was being run from the command line. These are the parameters which are valid for the runtime installation by itself - SDK/CLI commands are not supported. For example, the arguments could be `app.dll app_argument_1 app_argument_2`. This API specifically doesn't support the `dotnet run` SDK command.
239239
* `parameters` - additional parameters - see `hostfxr_initialize_parameters` for details. (Could be made optional potentially)
240240
* `host_context_handle` - output parameter. On success receives an opaque value which identifies the initialized host context. The handle should be closed by calling `hostfxr_close`.
241241

@@ -537,7 +537,7 @@ params.dotnet_root = get_directory(get_directory(get_directory(hostfxr_path)));
537537
hostfxr_handle host_context_handle;
538538
hostfxr_initialize_for_dotnet_command_line(
539539
_argc_,
540-
_argv_,
540+
_argv_, // For example, 'app.dll app_argument_1 app_argument_2'
541541
&params,
542542
&host_context_handle);
543543

@@ -594,4 +594,4 @@ The exact impact on the `hostfxr`/`hostpolicy` interface needs to be investigate
594594
Part if this investigation will also be compatibility behavior. Currently "any" version of `hostfxr` needs to be able to use "any" version of `hostpolicy`. But the proposed functionality will need both new `hostfxr` and new `hostpolicy` to work. It is likely the proposed APIs will fail if the app resolves to a framework with old `hostpolicy` without the necessary new APIs. Part of the investigation will be if it's feasible to use the new `hostpolicy` APIs to implement existing old `hostfxr` APIs.
595595
596596
## Incompatible with trimming
597-
Native hosting support on managed side is disabled by default on trimmed apps. Native hosting and trimming are incompatible since the trimmer cannot analyze methods that are called by native hosts. Native hosting support for trimming can be managed through the [feature switch](https://github.com/dotnet/runtime/blob/main/docs/workflow/trimming/feature-switches.md) settings specific to each native host.
597+
Native hosting support on managed side is disabled by default on trimmed apps. Native hosting and trimming are incompatible since the trimmer cannot analyze methods that are called by native hosts. Native hosting support for trimming can be managed through the [feature switch](https://github.com/dotnet/runtime/blob/main/docs/workflow/trimming/feature-switches.md) settings specific to each native host.

src/native/corehost/hostfxr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ struct hostfxr_initialize_parameters
8888
// Number of argv arguments
8989
// argv
9090
// Command-line arguments for running an application (as if through the dotnet executable).
91+
// Only command-line arguments which are accepted by runtime installation are supported, SDK/CLI commands are not supported.
92+
// For example 'app.dll app_argument_1 app_argument_2`.
9193
// parameters
9294
// Optional. Additional parameters for initialization
9395
// host_context_handle

0 commit comments

Comments
 (0)