How to create an MSIX package for WinForms app? - winforms

I'm trying to move to MSIX to install our application, which is currently deployed to our customers via a ClickOnce installation which requires updating on startup, if there is an update. Its a .Net Framework (4.7.2) WinForms app. I'm a bit lost on how to begin; the documentation seems to start from an existing installer package (including ClickOnce), but I'd like to generate this without an intermediate step on our build server as we want to phase out the ClickOnce installation completely once we've proven MSIX will work for us.
I found the Windows Application Packaging Project, but it seems targeted to UWP app, which ours is not, and we have the need to install on Windows 7 SP1 or higher.
What tool would I use to create an MSIX package non-interactively? Would the WAPP play any role in the process?

Here is a similar thread on MSFT's MSIX community. It's talking about VS 2017, but most of the info applies to 2019 too.
https://techcommunity.microsoft.com/t5/msix-packaging-and-tools/build-msix-from-vs-2017-pro-v-15-9-4/m-p/952246
An extract from the above link:
You should be able to use the windows application packaging project to package MSIX. Please see: https://learn.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-packaging-dot-net
Alternatively, you could package your MSIX by hand using: https://learn.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-manual-conversion
Additionally, if you want to use the MSIX Packaging Tool, you might be able to leverage our pre-made VM: https://learn.microsoft.com/en-us/windows/msix/packaging-tool/quick-create-vm even if your enterprise is still on an older release of windows.
You can also try partner solutions, like Advanced Installer's VS extension which can build an MSIX and MSI from the same project, if you need to target different users. The extension also supports debugging apps inside the msix container.
Disclaimer: I work on the team building Advanced Installer.

Related

CI/CD WPF setup file using Azure Pipelines

I have successfully created a Repo on Azure Devops and a Pipeline which triggers a release every time I push to the master branch. The result of the release is an .exe file that I can download from the Artifacts explorer. If I download the release and open it, the WPF app simply runs (no install required). I'm trying to wrap my head around how this whole CI/CD process would work but I just cannot find any good examples that could help me understand the deployment process(at least for WPF apps).
What I would usually do is build a WPF App, once I'm done, I add a new project to the solution (Visual Studio Installer - Setup Project) and deliver the .msi installer to the end user (for updates I send them the latest version to install).
How can I make this process a lot more smoother using CI/CD in Azure Devops? How do I generate an actual installer? Do I use some logic in the app itself to check for the latest build in Azure? Can someone please lay out some simple steps or some good resources?
You should be able to use a task like this: https://marketplace.visualstudio.com/items?itemName=dutchworkz.BuildInstaller to use the VS Installer project you have traditionally used.
This task wraps the calls to devenv that are needed to drive VS Installer to create its MSI package as it doesn't use the usual MSBuild engine to do this.
Other tools do a similar job, for example you could drive WIX or a similar tool to create the MSI package however if you are familiar with VS Installer Projects you may want to stick to this.

Prerequisites button disabled - MSI installer

I have created an .msi installer. I want to further add prerequisites (such as .Net) but when I go to Setup Project properties, the Prerequisites button is disabled. How do I enable it?
Other details:
I'm using VS 2015, SQL Server 2008 R2, .Net 4.5.2, C#, WinForms, Win
10 Pro x64
My setup project is in the same solution as the main project
Prerequisities in Visual Studio Projects
In Configuration at the top of the dialog, did you try to select either Release or Debug? That should enable the Prerequisites... button.
Unecessary, outdated prerequisites?
One pet-peeve of mine: is it really necessary to include the .NET runtime as a prerequisite when most users have it installed by their deployment team (corporations) or via Windows Update (home and small office users)?
If there are security updates for the runtime, your old, embedded runtime is just a nuisance to be honest. Corporate packagers spend a great deal of time removing runtimes and prerequisites for corporate deployment where all runtime components are packaged separately in the corporate standard format. Perhaps consider making a special corporate "large scale deployment" version of your setup bundle? Just a zip with components will be very appreciated, along with a one page PDF on how to deploy them.
For the .NET framework you could just add a launch condition to abort the installation if the runtime is not found, and tell the user to get the runtime via Windows Update or from their system administrator or deployment team.
Just a thought I wanted to share with you. Prerequisites can really bloat a setup - especially when they are almost never needed like the .NET framework. In the future we will certainly pull prerequisite packages straight from online repositories and not embed anything in our main setups (and probably struggle with new security issues from that approach).
What version of the .NET Framework is included in what version of the OS?
Selectively disable versions of the .NET Framework (.NET versions overwrite each other)
WiX and other deployment technologies
Setup projects are rather limited. If you find yourself needing more features, you might want to check out the WiX toolkit.
Here is a previous answer on WiX and other deployment tools that seems to have been helpful for people: MSI vs nuget packages: which are is better for continuous delivery?

WPF and ClickOnce

MSDN does not list a WPF .exe as a supported type of application for ClickOnce
A ClickOnce application is any Windows Presentation Foundation
(.xbap), Windows Forms (.exe), console application (.exe), or Office
solution (.dll) published using ClickOnce technology.
http://msdn.microsoft.com/en-us/library/t71a733d.aspx
I do find evidence around the web that non-XBAP WPF apps work with ClickOnce, but are they officially supported?
Yes, ClickOnce does support WPF applications compiled to executables. ClickOnce is nothing more than an installation distribution method. The primary difference between creating an installation package and ClickOnce (other than being web-based) is that ClickOnce applications are installed within obfuscated folders within the end user's Windows directory.
The means that ClickOnce applications can be installed with a non-administrator account. The caveat to this method is that an application can not be installed on a PC and shared across other user accounts on the PC-- each user must re-install the application.
WPF requires the .NET 3.0+ framework. When you publish your ClickOnce application, you will need to include the .NET 3.0 (or 4.0) framework. Once you add the prerequisite to your project, ClickOnce will check the user's PC to see if the framework is installed. If not, it will pre-install it before installing and running your application. If it already exists, it will skip the download and installation of the framework.
If you need to install a third-party library or application, custom pre-requisites can be created and added to your projects. It is worth noting, prerequisites may need to be installed by an administrator, depending on the rights of the end user. This may seem a bit counter-intuitive, but it's just the nature of the installation process.
ClickOnce is a very simple, but robust installation mechanism, and I've used it extensively. It's not appropriate for every circumstance, but it can certainly accomplish what you are asking.
For ClickOnce, there is no difference between a Windows Forms executable and a WPF executable. Both are .NET executables and as such fully supported by ClickOnce...
I have personally deployed several WPF desktop applications using ClickOnce, and it worked exactly the same as with my Windows Forms applications...

How to Deploy WPF application using MSI

I have a WPF C# desktop application that will need to be deployed as MSI (Windows Installer deployment, not ClickOnce deployment) in VS2010. My application will generate SQL CE database in run-time, manipulate Excel Workbook, and receive/transmit data from/to COM Port - so I don't know what is the appropriate way to deploy such an application.
I am looking at Windows Installer Deployment Tasks which doesn't help me to get started.
Could anyone show me some resources that give instructions on how to deploy an application as an MSI installer?
If you don't want ClickOnce, then you'll probably need to create your own MSI. In that case, you can use:
The built-in Setup project type in Visual Studio. It does a decent job but has limitations. Works very well if you don't have many dependencies or custom actions.
A commercial tool like InstallShield
WIX (Windows Installer XML)
I've tried both 1 and 3. While WIX has a little bit of a learning curve, it is a very rich way to do what you want to do. There is a fair bit of documentation available and some very nice "out of the box" wizard sequences to handle your standard install scenarios (licenses, feature selection, dependencies, etc). WIX does have some VS integration that works quite well.
You can find out more on WIX at http://wix.sourceforge.net/
Note:
The VS setup project can do custom actions, and install dependencies, but you have to use custom actions. If you want to parameterize the custom actions, then you'll need to find the not-so-intuitive instructions on that topic.
The other limitation of the VS setup project is that the setup project can only be compiled to an MSI by VS (devenv.exe). That means that the MSI cannot be compiled on a build server unless you install Visual Studio there too. This was a show stopper for me, so I switched to WIX and was very happy with the result.
For those like me who found this post after searching high and low for how to deploy an MSI these days, you now need an extension as the visual studio team removed the built in startup project functionality. You now need to download the Visual Studio Installer Projects extension.
See this user voice post for discussion of the removal, and here is a link to the extension.
Useful for people looking for a quick solution to generating an MSI through Visual Studio rather than getting deep into Wix (although if you need more advanced deployment options, definitely go that route).
Configure your WPF application to publish as a ClickOnce application. You can do that in the 'Publish' tab of the project properties.
If you use the 'Publish Wizard' (by clicking on the aptly named button on the properties page) you can specify (on the second page) that the user will install 'From a CD-ROM or DVD-ROM'. This option will produce a setup.exe file in the publish sub-folder of your project output directory. This setup.exe program when launched by your user will install the WPF application. You may choose to include an update functionality (but you don't have to).
The ClickOnce settings also allow you to include additional files (e.g., your SQL CE database file) and pre-requisites if necessary.

What package of .Net framework is required on target client machine in order to run .Net winforms application?

I'm Trying to deploy my winforms project using installshield in order to make is available to be installed on other computers. My project is written under .net framework 3.5.
My question is : What version of .net package should be installed on the target machine in order to be able to run my project?
One thing to notice is that target machine is not connected to internet so I have to embed a standalone offline installer for .net framework.
Surely, with .Net framework 3.5 full redistributable package installed, my project runs fine. But it's ~200MB. Should I really install 200MB in order to run my ~10MB project on target machine?
one other option would be installing client redistributable package which I heard ~30MB. But I couldn't find any official release and am not sure if that's gonna work.
Any help would be appreciated.
You should deploy with the web installer so that it can determine what your client needs and download only those components. The full install is that big because it contains all variants of the framework for all possible systems (x86, x64, etc.).
This site from Scott Hanselman is an excellent resource on the matter of deploying .NET.
http://www.hanselman.com/smallestdotnet/
As it states on that site:
If you look for .NET Downloads on
Microsoft's site, it might look like
the .NET Framework is 200+ megs. It's
not. Those big downloads are the
Complete Offline Versions of every
version of the .NET Framework for
every kind of machine possible. The
big .NET download includes x86, x64,
and ia64. It includes .NET 2.0, 3.0,
and 3.5 code for all systems all in
one super-archive.

Resources