In the introduction blog to Installing Windows Server Apps on Nano, I introduced the concept of Windows Server Apps (WSAs) and using APPX to install them on Nano Server. Now it is time for a hands-on tutorial to package your first WSA and get it installed on Nano Server.
Since the APPX format was released in Windows 8, a full toolchain has been built around it. We leverage those existing APPX tools to create and install WSAs on Nano Server. I personally found the blog Designing a simple and secure app package – APPX very informational, and it should help to get you started.
To create and install a WSA with the Windows Server-specific extensions of APPX on Nano Server, you will need to install a Nano Server base image and the Windows 10 SDK from the Technical Preview 4 release. The Nano Server base image contains the Server extensions of the APPX framework and the Certoc tool. The Windows 10 SDK includes APPX packaging tools for:
You can find more info on how to use these tools here.
Creating an WSA package
The first step in creating your WSA is to create a folder structure with your application files and then add a manifest in an “AppxManifest.xml” file. You can use a simple text editor to create the manifest manually. Refer to this MSDN help page on how to create a basic APPX manifest XML. In addition to the basic APPX manifest, you will need to add Windows Server specific content in the manifest, including:
Namespace attribute for <Package>
Windows Server <extension> element
For Technical Preview 4 release, you can specify the following extensions: NT Services, WMI Providers, COM Servers/Interfaces/AppIds.
Please refer to the sample AppxManifest.xml in the blog for details.
Once you’ve completed the manifest, you can use MakeAppx.exe to package your WSA.
For those who currently use the WiX Toolset to produce MSI packages, FireGiant developed an extension for the WiX Toolset to create APPX packages. Their extension allows you to use the same WiX project to generate an APPX for Nano Server and an MSI for all other platforms. See FireGiant's APPX support for the WiX Toolset page for more information.
For package integrity, all APPX packages must be digitally signed. This rule continues to hold when you package a WSA. You can use MakeCert.exe and Pvk2Pfx.exe to create a certificate. Then use Signtool.exe to sign the package with this certificate. For example:
C:\Program Files (x86)\Windows Kits\10\bin\x64\MakeCert.exe /n "CN=Contoso Software, O=Contoso Corporation, C=US" /r /h 0 /eku "184.108.40.206.220.127.116.11.3,18.104.22.168.4.1.322.214.171.124" /e 12/12/2015 /sv Contoso.pvk Contoso.cer
C:\Program Files (x86)\Windows Kits\10\bin\x64\Pvk2Pfx /pvk Contoso.pvk /pi <password> /spc Contoso.cer /pfx Contoso.pfx /po <password>
C:\Program Files (x86)\Windows Kits\10\bin\x64\Signtool.exe sign /fd SHA256 /a /f Contoso.pfx /p <password> test.appx
At this stage, you have completed all the setup requirements and created a WSA package ready to be installed.
Installing on Nano Server
Now let’s change our role from a setup developer to an ITPro who wants to install a software program on Nano Server. You first must confirm and allow certificates from the program’s publisher that produces the products. This can be done using Certoc.exe in Nano Server.
C:\Windows\System32>.\certoc.exe –addStore TrustedPeople c:\packages\ Contoso.cer
For installation, we provide TWO sets of PowerShell cmdlets. The first set leverages existing APPX PowerShell cmdlets, including:
- Remove-AppxPackage <PackageFullName>
You will need to first copy the APPX package to your Nano Server, and then issue Add-AppxPackage to install it.
The second set leverages PackageManagement cmdlets. This set has added package repository management for local and network shares on top of package level operations. You do not need to manually copy the APPX package to Nano Server. Instead, you only configure the APPX PackageManagement provider on first use:
Import-PackageProvider –Name Appx
Register-PackageSource –Provider appx –Name appxSrc –Location \\yourNetworkShare
From now on, you can discover, install, do inventory, and uninstall the package without specifying the package location:
- Find-Package –Provider appx
Install-Package –Provider appx –Name <packageName>
Get-Package –Provider appx
We are still in the early stages of the APPX journey on Nano Server and therefore the cmdlets have rough edges in the Technical Preview 4 release. You will find not all the parameters listed in Get-Help and only a subset of the cmdlet parameters work. For instance, -Volume, -DependencyPath, and -ForceApplicationShutdown parameters are not supported yet in APPX cmdlets. The PackageManagement APPX provider wraps APPX cmdlets to the generic PackageManagement cmdlets which will expose the same limitation.
Please give it a try! We are always happy to hear your feedback!