MSix Packaging Project
Tags: deployment, desktop, winforms, wpf
Published: 2019-11-11 08:29:58

Deployment is hard.  Arguably, deployment is the reason the web apps have won over desktop apps.  I've seen applications written as web apps that would have been easier, faster and more reliable written as desktop applications; however, the deployment problem is such a big factor, that these days, you have to have such a compelling reason to create a desktop application that they are almost unheard of.

With .Net Core 3, came a new attempt from Microsoft to make this whole deployment process easier.  MSix allows you to take a Winforms or WPF application, and package it up in a very similar way to that used for UWP.  You can then deploy these to the Windows Store; or, you can self host them, and deploy them from your own web-site.

Using an MSix does solve a number of deployment problems; for example, it pretty much picks up where ClickOnce left off.  It guarantees that you're not installing anything horrendous on your machine, because the packaging process sandboxes the application.

However, it is, by no means, perfect.  This post covers how you can create a side-loaded deployment project.  As a disclaimer, I used <a href="https://montemagno.com/distributing-a-net-core-3-wpf-and-winforms-app-with-msix/">this</a> post from James Montemagno as a base for this; however, there were a couple of parts where I got stuck with his post, so hopefully this fills in some gaps.

The post assumes that you have a WPF or WinForms application that you wish to deploy, and that you're using Visual Studio.

	
	
### - Set runtime identifier:

```

<PropertyGroup>
    <!--Regular Settings-->
    <Platforms>AnyCPU;x64;x86</Platforms>
    <RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
    <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
```


### - Create new Windows Application Packaging Project in your solution:

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-1.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-1.png" alt="" width="1280" height="888" class="alignnone size-full wp-image-3969" /></a>

### - Name project:

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-2.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-2.png" alt="" width="1280" height="888" class="alignnone size-full wp-image-3968" /></a>	

### - Pick a minimum and target version:

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-3.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-3.png" alt="" width="702" height="274" class="alignnone size-full wp-image-3967" /></a>

### - Add reference to the project to deploy.  That is, reference the project that you wish to be deployed by your packaging application:

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-4.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-4.png" alt="" width="439" height="609" class="alignnone size-full wp-image-3966" /></a>

### - Create App Packages (if you were publishing to the store, and you'd already created the app in the store, this is where you would diverge from these instructions):

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-5.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-5.png" alt="" width="790" height="643" class="alignnone size-full wp-image-3965" /></a>


### - Select Sideloading (if you were registering a store app for the first time, this is where you would diverge from these instructions):

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-6.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-6.png" alt="" width="785" height="673" class="alignnone size-full wp-image-3964" /></a>


### - Create a test certificate:
	
<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-7.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-7.png" alt="" width="785" height="673" class="alignnone size-full wp-image-3963" /></a>


### - Set-up version and target platforms:

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-8.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-8.png" alt="" width="785" height="673" class="alignnone size-full wp-image-3962" /></a>


### - Create a distribution web site (<a href="https://docs.microsoft.com/en-us/windows/msix/app-installer/web-install-azure">https://docs.microsoft.com/en-us/windows/msix/app-installer/web-install-azure</a>):

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-9.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-9.png" alt="" width="1920" height="937" class="alignnone size-full wp-image-3961" /></a>

Contrary to what this screenshot may lead you to believe, don't bother doing anything to it just yet - just create it so that you have the URL.


### - Deploy the app packages (you'll need the URL from above):

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-10.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/msix-10.png" alt="" width="785" height="673" class="alignnone size-full wp-image-3960" /></a>


### - Once you've published the app, install the test certificate to Local Machine -> Trusted Root Certificates.  Obviously, were you to do this in real life, you'd need a kosher certificate.

### - FTP the entire contents of the AppPackages directory to the site.  To find the FTP details, select the deployment centre:

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/installer-1.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/installer-1.png" alt="" width="320" height="395" class="alignnone size-full wp-image-3978" /></a>

From here, select FTP:

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/installer-2.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/installer-2.png" alt="" width="1461" height="700" class="alignnone size-full wp-image-3977" /></a>

Once you select FTP, a Dashboard button will appear at the bottom of the screen, select that, and the FTP credentials should appear:

<a href="https://www.pmichaels.net/wp-content/uploads/2019/11/installer-3.png"><img src="https://www.pmichaels.net/wp-content/uploads/2019/11/installer-3.png" alt="" width="792" height="650" class="alignnone size-full wp-image-3979" /></a>

### - Create the default.html, as shown above; clearly, you'll need your own link, but the format should be the same as mine.

That's it - you should have a web-site with a link that allows you to install a desktop application locally (albeit you'll need the certificate installed on the local machine).


<h1>References</h1>

<a href="https://montemagno.com/distributing-a-net-core-3-wpf-and-winforms-app-with-msix/">https://montemagno.com/distributing-a-net-core-3-wpf-and-winforms-app-with-msix/</a>

<a href="https://docs.microsoft.com/en-gb/windows/msix/app-installer/web-install-azure">https://docs.microsoft.com/en-gb/windows/msix/app-installer/web-install-azure</a>

<a href="https://www.advancedinstaller.com/install-test-certificate-from-msix.html">https://www.advancedinstaller.com/install-test-certificate-from-msix.html</a>