Jaa


Hands-on Packaging and Installing your first Windows Server Apps on Nano Server

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.

Prerequisites

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:

  1. Namespace attribute for <Package>

  2. <TargetDeviceFamily> element

  3. 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 "1.3.6.1.5.5.7.3.3,1.3.6.1.4.1.311.10.3.13" /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:

  • Add-AppxPackage <packageName.appx>

  • Get-AppxPackage

  • 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

  •    Uninstall-Package <packageName> 

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!

sample-AppxManifest.xml

Comments

  • Anonymous
    March 22, 2016
    Is there a schema available that describes the WSA extensions?
  • Anonymous
    March 28, 2016
    Hi,

    Could someone help me in figuring out the location of fgwixappxextension.wixext.dll? i couldn't find in WIX toolset.

    Thanks
  • Anonymous
    July 03, 2016
    I tried to create the APPX package using below manifest file.""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SampleService Microsoft Corporation Microsoft Monitoring Agent logo.png false true """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""After installing the package successfully, I could find the location were the executable "sample.exe" is copied.
    • Anonymous
      July 03, 2016
      Below is the manifest file sample SampleService Microsoft Corporation Microsoft Monitoring Agent logo.png false true
  • Anonymous
    September 19, 2016
    Are there any "sandboxing" constraints for applications running as a WSA? I'm seeing permissions errors when an appx packaged application attempts to create a file. If I copy that application's InstallLocation to another directory outside of WindowsApps, it can create the files just fine. I understand the merits here for a consumer based windows store app, but this can be a show stopper for many server based applications.
  • Anonymous
    April 15, 2017
    I created a WSA package using WiX, WiX Extension Pack and IsWiX. I'm trying to install it on nano server but I can't find "certoc.exe" anywhere on the c drive. I tried to issue the Add-AppXPackage command but I get an error message saying I need to have a developer license or enable side loading. How do you enable side loading on nano server?