.net core application报错The required library hostfxr.dll could not be found.

For programs generated by .Net Core and Framework, .Net Core needs to be applied in the running environment. If you throw it directly to others, an error will be reported.

:\Program Files (x86)\***>.\copyfiles.exe
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 [C:\Program Files (x86)\BiMass\].
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 to specify the runtime location or register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x64\InstallLocation].

The .NET runtime can be found at:
  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=win10-x64&apphost_version=6.0.5

Reference connection

.net core publishes a single exe file and optimizes the size

  1. Run build
    dotnet build
  2. Create a package based on the x64 system.
    dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true
    At this time, the win-x64 file will be generated. There is a publish folder in it. The files in it can have their own running status for others to use.
    Insert image description here
    Insert image description here
    Insert image description here

Guess you like

Origin blog.csdn.net/qq_41059339/article/details/126644268