Loading a self-contained executable with custom runtime host returns error about missing .deps.json file
#76,080 创建于 2022年9月23日
仓库指标
- Star
- (17,886 star)
- PR 合并指标
- (平均合并 12天 11小时) (30 天内合并 661 个 PR)
描述
Description
Using hostfxr_initialize_for_dotnet_command_line to load a self-contained executable with a custom runtime host app fails due to a missing .deps.json file (even though it shouldn't be present in self-contained apps?).
Reproduction Steps
- Create a default .NET 6 console app project
- Publish it with the following settings:
- Deployment mode: self-contained
- Target runtime: win-x64
- ✅ Produce single file
- Create a custom runtime host, as per Microsoft documentation
- Replace the
init_fptrcall (with thehostfxr_initialize_for_runtime_configsignature) forhostfxr_initialize_for_dotnet_command_line - Compile the C++ executable and put the self-contained executable alongside it
- Add
COREHOST_TRACE=1andCOREHOST_TRACE_VERBOSITY=4to environment variables for logging - Launch the host app and observe missing .deps.json and hostpolicy.dll errors in console output.
Expected behavior
Call to hostfxr_initialize_for_dotnet_command_line to pass without issues (return code = 0, valid host context returned).
Actual behavior
Host context fails to initialize with error code 0x80008083, and following logs are displayed: (truncated = full path to both the SCD executable and native host executable)
--- Invoked hostfxr_initialize_for_dotnet_command_line [commit hash: 55fb7ef977e7d120dc12f0960edcff0739d7ee0e]
Checking if CoreCLR path exists=[C:\Program Files\dotnet\host\fxr\6.0.8\coreclr.dll]
--- Executing in muxer mode...
Using the provided arguments to determine the application to execute.
App runtimeconfig.json from [<truncated>\UE5InteropManaged.exe]
Runtime config is cfg=<truncated>\UE5InteropManaged.runtimeconfig.json dev=<truncated>\Internal_LocalDev\bin\UE5InteropManaged.runtimeconfig.dev.json
Attempting to read runtime config: <truncated>\UE5InteropManaged.runtimeconfig.json
Attempting to read dev runtime config: <truncated>\UE5InteropManaged.runtimeconfig.dev.json
Runtime config [<truncated>\UE5InteropManaged.runtimeconfig.json] is valid=[1]
Executing as a self-contained app as per config file [<truncated>\UE5InteropManaged.runtimeconfig.json]
--- Resolving hostpolicy.dll version from deps json [<truncated>\UE5InteropManaged.deps.json]
Cannot use file stream for [<truncated>\UE5InteropManaged.deps.json]: No such file or directory
The expected hostpolicy.dll directory is [C:\Program Files\dotnet\]
The hostpolicy.dll was not found in [C:\Program Files\dotnet\]
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet\'.
Failed to run as a self-contained app.
- The application was run as a self-contained app because '<truncated>\UE5InteropManaged.runtimeconfig.json' was not found.
- If this should be a framework-dependent app, add the '<truncated>\UE5InteropManaged.runtimeconfig.json' file and specify the appropriate framework.
Regression?
Not aware, haven't tested on previous versions of .NET.
Known Workarounds
Not aware (not using a self-contained distribution would not be ideal for the target use-case).
Configuration
.NET version: 6.0.8 OS: Windows 11 21H2 (22000.978) Architecture: x64 Is error specific to environment: not aware, haven't tested on Linux Using Blazor: no, the managed app is a standard console application
Other information
No response