使用 MSI 安装程序部署 .NET 5 WPF 应用程序 [英] Deploying .NET 5 WPF application using MSI installer

查看:29
本文介绍了使用 MSI 安装程序部署 .NET 5 WPF 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人使用 Visual Studio 安装项目来部署 .NET 5 WPF 桌面应用程序?我多年来一直在做这些事情,但是使用 .NET 5,事情似乎发生了一些变化.我尝试按照 MS 在 这篇文章,主要针对 .NET Core 3.1,但我找不到任何特定于 .NET 5 的内容.

Has anyone used Visual Studio Setup Project to deploy a .NET 5 WPF desktop application? I have been doing this stuff for years, but with .NET 5, things seem to have changed a bit. I tried to follow the steps provided by MS in this article, which primarily targets .NET Core 3.1, but I couldn't find anything specific for .NET 5.

与 .NET Framework WPF 应用程序不同,我们将主要项目输出添加到我们的安装程序项目中,本文要求我将发布的项目添加到安装程序.我这样做了,但现在无法创建快捷方式"在用户的桌面或开始菜单上,因为快捷方式要求我选择一个可执行文件,而在这种情况下我没有.

Unlike .NET Framework WPF applications, where we add Primary Project Output to our installer project, this article asks me to add Published Items to the installer. I did that but now there is no way to create a "Shortcut" on user's desktop or start menu, because shortcuts require me to select an executable, which I do not have in this case.

一个稍微不同但相关的问题是,我无法在安装程序项目中选择我的应用程序图标,因为我的 WPF 项目在安装程序中也没有主要输出.

A slightly different but related problem is that I can't select my application's icon in the installer project because again I do not have primary output of my WPF project in the installer.

推荐答案

好的.经过一些更多的实验,我发现了以下内容:

OK. After some more experimentation I found the following:

  • 创建指向已发布项目的快捷方式是可以的.当用户在安装后单击此快捷方式时,它只会在您发布的文件夹中打开可执行文件.所以不需要主要项目输出.
  • 要将您的应用程序图标用于快捷方式和添加/删除程序,只需将您的 ico 文件手动添加到您的安装文件夹并将其 排除 属性设置为 真的.这样,它将在图标浏览对话框中可用,但不会注入到用户的安装文件夹中.
  • Creating a shortcut that points to Published Items is okay. When user clicks this shortcut after installation, it will simply open the executable in your published folder. So no need of the Primary Project Output.
  • To use your application icon for the shortcuts and Add/Remove Programs, just add your ico file manually to your installation folder and set its Exclude property to true. This way it will become available in the icon browse dialog, but not injected into user's installation folder.

我还找到了一些在我的案例中不需要的更高级的解决方案,但可能对其他人有帮助.有 这篇文章 来自供应商自己,教一种通过脚本修改安装程序数据库的方法,以及 这个相关的 SO帖子展示了使用安装程序 UI 组件执行相同操作的技巧.

I also found a couple of more advance solutions that I didn't need in my case, but might be helpful for someone else. There is this post from the vendor themselves that teaches a way of modifying the installer database through script, and this related SO post that shows a trick of doing the same using installer UI components.

这篇关于使用 MSI 安装程序部署 .NET 5 WPF 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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