【问题标题】:Create a standalone exe file in Visual Studio 2019在 Visual Studio 2019 中创建独立的 exe 文件
【发布时间】:2021-10-31 03:06:03
【问题描述】:

我想从我的 WPF 项目中创建一个 exe 文件,它可以在没有其他项目文件的情况下工作,并且可以在不同的计算机上运行。 目前,我在 Build > Publish ProjectName 中使用 Publish 功能,有以下选项:

配置文件名称:FolderProfile
删除现有文件:false
配置:发布 |任何 CPU
目标框架:net5.0-windows
部署方式:依赖框架
目标运行时:便携式
目标位置:\bin\Release\net5.0-windows\publish\

即使成功发布,我在目标位置发现各种文件,当我将exe复制到不同文件夹中时,外部到项目文件夹,它不起作用并且没有出现任何窗口。

有什么建议吗?谢谢!

【问题讨论】:

  • 这能回答你的问题吗? Merging dlls into a single .exe with wpf
  • VS 中没有与--self-contained CLI 选项等效的选项吗? docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish
  • 目前,我在 Developer PowerShell 中使用命令字符串(在 Solution Explorer 中右键单击解决方案名称 -> 在终端中打开)。字符串命令是dotnet publish -c release --self-contained -r win-x64 -p:PublishSingleFile=true。我收到此错误:C:\Program Files\dotnet\sdk\5.0.302\NuGet.targets(131,5): error : Unable to load the service index for source api.nuget.org/v3/index.json 我的电脑未连接,所以可能这就是我收到错误的原因。有没有其他方法可以在不需要互联网连接的情况下发布单个 .exe 文件?

标签: c# wpf deployment visual-studio-2019 publish


【解决方案1】:

您可以尝试以下步骤:

  1. 右键单击项目并选择发布。
  2. 选择你要部署的位置,例如我选择文件夹,然后next->finish。
  3. 单击编辑,将部署模式设置为自包含,展开文件发布选项,然后选择生成单个文件。

【讨论】:

    猜你喜欢
    • 2012-06-21
    • 1970-01-01
    • 2013-12-06
    • 2011-01-03
    • 2017-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多