Search code examples
.net-corewindows-installer.net-5visual-studio-setup-proje

Deploying .NET 5 WPF application using MSI installer


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.

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.

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.


Solution

  • OK. After some more experimentation I found the following:

    • 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.

    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.