This article is more than 1 year old

Hands On with Project Centennial: A better app installer for Windows

Documentation could be better, but this is a real reason to upgrade

Hands On Even those who do not care about Microsoft’s Universal Windows Platform (UWP) might have some interest in Project Centennial, also known as the Desktop App Converter, which lets you convert desktop applications to the Appx format used by Windows Store apps.

The ability to have Appx packages install desktop applications is a feature of Windows 10 Anniversary, which will be released in August 2016. The advantage of working with Appx packages is that they can be installed and removed cleanly, unlike conventional Windows setup routines which may install files in numerous places and add system components and Registry entries which cannot easily be removed. Windows systems often get slower over time, especially those on which applications are frequently installed and removed, so a better way of managing this process is a significant benefit.

Project Centennial also means that Store submission will be possible in future, although this does not work with the current preview.

A Project Centennial application is less well isolated (and therefore less secure) than a true UWP application. That said, it does have restrictions which prohibit certain kinds of behaviour which might damage the operating system.

Installing the Desktop App Converter, presuming you have a supported preview build of Windows 10 Anniversary, is a matter of downloading a Windows Image File (.WIM) that matches your Windows 10 build, along with various utilities and PowerShell scripts. You also need the Windows 10 SDK. The Desktop App Converter uses a Windows 10 container, a lightweight form of virtualization, to make a clean install of the target application. It then captures the changes made to the system and creates an appx package from the result.

I tried the Desktop App Converter with a simple Windows Forms application, the old style of .NET desktop applications. Writing the application in Visual Studio 2015 was a snap, but I found that to use the Desktop App Converter I needed an installer, otherwise the conversion script cannot run. I added an extension to Visual Studio that supports Installer projects, and built a basic setup project.

The installer has to run silently, since the converter launches the installer in an invisible container and waits for it to exit. You can specify arguments to pass to the installer, but if it requires the user to click a dialog or agree a EULA, the converter will fail.

A .NET desktop application running via Project Centennial

This is a Windows Forms application running via Project Centennial, but you will have to take my word for it because it looks identical to the unconverted version.

After a couple of false starts, everything worked and I had an Appx package. The final step is to sign the Appx - I used a self-generated certificate - and install it with the PowerShell command Add-AppxPackage. The application then appeared in the Windows 10 Start menu and worked exactly as before. It does not appear in the Windows 10 Programs and Features list, but you can uninstall by right-clicking the application shortcut and choosing Uninstall.

I soon discovered how to improve the process though. If you run the Desktop App Converter according to the tutorial, it generates a bunch of files, including the critical AppManifest.xml which sets various attributes of the Appx package as well as bitmaps which are used for the shortcuts, and then runs a tool called MakeAppx (part of the Windows 10 SDK) to build the final Appx file. This means you cannot tweak the output, other than by changing the arguments to the Converter and running it again.

It is more flexible to run the converter without the MakeAppx argument. Then you can make edits to AppManifest.xml and the rest of the output, and run MakeAppx manually.

Doing this helped me to understand that use of the Desktop App Converter is actually optional. If you have an installer which does stuff like COM registrations, funky copy protection or files placed in strange locations for reasons known only to the developer, then its use for capturing the results is near essential. On the other hand, if your application is a single executable, or installs everything into its own application folder, then you can bypass the Converter and just use MakeAppx, as explained here.

The core of Project Centennial is not the App Converter, but rather the changes in the UWP which allow desktop applications to run. If you look in AppManifest.xml you will see things like Capability set to “runFullTrust” and EntryPoint set to “Windows.FullTrustApplication”. This is what is new in Windows 10 Anniversary.

I was reminded of a remark at the Project Centennial session at Microsoft Build 2016, that there is no such thing as a Centennial app, only Centennial extension points for the UWP.

The current tools enable developers to try the preview, but in future many installer kits will simply offer an option to package as Appx, so that for new applications support will be more or less a matter of checking a box.

The same but different

What changes when you run a desktop application converted to an Appx, as opposed to running that application directly?

There are three main differences. The first is that calls to the Registry and to certain file system locations are redirected. If your application installs files to the Windows directory, or System32, or writes to Program Files after installation, for example, those calls are directed to the application folder. It also uses the UWP isolated storage, rather than the usual AppData folder, for local storage. However, calls to the file system outside these special areas are unaffected. It could write to a directory under the root of the C drive, for example, and that would work as before.

Second, these applications must run as a standard user. They cannot be elevated to run as Administrator. Nor can they run as a Windows service, though they can run background tasks and they can run automatically on start up.

Third, the entire API of the UWP is available, whereas desktop applications only have access to a subset of the UWP. This includes live tiles, app services that enable communication, share contracts, and so on. It is possible to create applications that have two processes, one running as a desktop application, and the other as a normal UWP app. Microsoft’s hope is that developers will gradually migrate features across to the UWP side, until the desktop portion is no longer needed. This could also be a long-term strategy though, to appear to the user as a UWP app while still using legacy desktop code.

Project Centennial Pros and Cons

Microsoft’s UWP has had mixed fortunes since its launch with Windows 10. The rapid decline of Windows Phone and lack of Windows 7 support spoils the “Universal” part of its name, and limitations versus traditional desktop applications make porting difficult. The developer tools for the UWP are way behind what is available for desktop apps.

Project Centennial removes most of those limitations and has the potential to improve the Windows experience both for businesses and consumers. The Windows 10 Store will get more applications that users actually want to install, and setup and removal becomes easier and more manageable. Porting an application to Appx using these tools is not always trivial – check the list of limitations and edge cases here – but in many cases they will just work. One snag that affects many existing applications is that .NET applications must target version 4.6.1 or higher, though oddly my .NET 4.5 example worked fine. This will be a problem though if you do not have access to the code.

The biggest issue of course is if you need to continue supporting versions of Windows earlier than Windows 10 Anniversary. This may mean maintaining two slightly different versions of a desktop application, one with a traditional install, the other converted to Appx.

An alternative is Microsoft's existing App-V product, aimed at enterprises who want to package applications in order to automate deployment and remove the risk of dependency conflicts. App-V works fine with Windows 7, but does not integrate with the UWP or the Windows Store.

In a sense, Project Centennial is App-V for everyone, and a solid reason for considering a Windows 10 rollout.®

More about

More about

More about

TIP US OFF

Send us news


Other stories you might like