用 .NET 5.0 编写的控制台应用程序无法在同事的计算机上运行 [英] Console Application written in .NET 5.0 unable to run on colleague's computer

查看:24
本文介绍了用 .NET 5.0 编写的控制台应用程序无法在同事的计算机上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 .NET 5.0 中编写了一个工具,我现在必须将其提供给非开发人员使用.不幸的是,无论我如何发布它,我都无法让它在她的计算机上运行.目前我已将其设置为:

I wrote a tool at work in .NET 5.0 that I now have to give to a non-developer to use. Unfortunately, no matter how I publish it I can't get it to run on her computer. Currently I have it set at:

配置: 发布 |任何 CPU
目标框架: net5.0
部署模式:独立
目标运行时: win-x64(检查过,她肯定有 Windows 10 64 位)

Configuration: Release | Any CPU
Target framework: net5.0
Deployment mode: Self-contained
Target runtime: win-x64 (checked that, she definitely has Windows 10 64-bit)

但是当她在她的 PC 上运行它时,她得到:

But when she runs it on her PC she gets:

Failed to load the dll from [C:UsersusernameDesktopRelease Builderhostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from C:UsersusernameDesktopRelease Builderhostfxr.dll failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=798306

当然,我检查了链接,她的 Windows 10 的最低版本高于最低版本.这是怎么回事?我习惯于构建 Web 应用程序或只是为自己构建控制台工具.我认为独立意味着只需移交发布文件夹的内容.

I, of course, checked the link and she has above the minimum version of Windows 10. What gives? I'm use to either building web applications or just building console tools for myself. I figured self-contained would mean just handing over the contents of the publish folder.

我应该指出,发布文件夹似乎是正确的...里面有 230 多个文件.

I should point out, that the publish folder APPEARS to be correct... its over 230 files in there.

推荐答案

您可以尝试使用这些设置进行发布吗?

Can you try to publish with these settings?

第 1 步:

第 2 步:打开您的 .csproj 并添加这些,或与您的交换.

Step 2: Open your .csproj and add these, or swap with yours.

  <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 5.0 编写的控制台应用程序无法在同事的计算机上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆