Self-contained .net core 3.1 app giving hostxfr.dll not found

320 views Asked by At

I have a win-x64 app which is c++ calling a C++/CLI .Net Core DLL which is in turn calling a C# .Net core 3.1 DLL. It works fine on my development computer.

I've setup all of the projects to copy all of the depenencies and the C# project post build step has

dotnet restore -r win-x64
dotnet publish "$(ProjectFileName)" -r win-x64 --no-build -c $(ConfigurationName) -o $(OutDir) --no-restore -p:PublishReadyToRun=true --self-contained true

I copied the EXE and all of the DLLs to the target machine and they're all in one directory (including the hostxfr.dll file that its complaining it can't find). When I run it with set COREHOST_TRACE=1 I get

Can't open the SDK installed location registry key, result: 0x2
Using global installation location [C:\Program Files\dotnet] as runtime location
.
A fatal error occurred. The required library hostfxr.dll could not be found.
If this is a self-contained application, that library should exist in [].
If this is a framework-dependent application, install the runtime in the global
location [C:\Program Files\dotnet] or use the DOTNET_ROOT environment variable t
o specify the runtime location or register the runtime location in [HKLM\SOFTWAR
E\dotnet\Setup\InstalledVersions\x64\InstallLocation].

The .NET Core runtime can be found at:
  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=win81
-x64
Failed to start the .NET Core runtime. Error code -2147450749

I tried setting DOTNET_ROOT=the target dir name -- that didn't help. I tried removing the ready-to-run flag and rebuilding - that didn't help either.

What magic incantation do I need to fix this?

0

There are 0 answers