我在 .NET 5.0 中编写了一个工作工具,现在必须将其提供给非开发人员使用。不幸的是,无论我如何发布它,我都无法让它在她的计算机上运行。目前我将其设置为:
配置:发布 |任何CPU
目标框架: net5.0
部署模式:自包含
目标运行时: win-x64(检查过,她肯定有 Windows 10 64 位)
但是当她在 PC 上运行它时,她得到:
Failed to load the dll from [C:\Users\username\Desktop\Release Builder\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from C:\Users\username\Desktop\Release Builder\hostfxr.dll failed
- Installing .NET prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=798306
我当然检查了链接,她拥有高于最低版本的 Windows 10。有什么好处?我习惯于为自己构建 Web 应用程序或只是构建控制台工具。我认为独立意味着只需移交发布文件夹的内容。
我应该指出,发布文件夹似乎是正确的......其中包含超过 230 个文件。
最佳答案
您可以尝试使用这些设置进行发布吗?
第 1 步:
第 2 步:打开您的 .csproj
并添加这些内容,或与您的进行交换。
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<UseWPF>true</UseWPF>
// keep other info
</PropertyGroup>
关于.net-core - 用.NET 5.0编写的控制台应用程序无法在同事的计算机上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67418774/