Oct 7, 2016

How to Convert Windows Apps to Universal Windows Platform Apps with Desktop Bridge


If you're looking to bring your traditional app to the Universal Windows Platform, this guide walks you through the steps to use the DesktopAppConverter to convert your app. In this Windows 10 guide, we'll walk you through the steps to convert a traditional desktop application into a Universal Windows Platform app.






On Windows 10, Microsoft is not only adding new features and making the operating system more secure, but it's also investing on making the Windows Store the single place for users to acquire apps.

The caveat with the Windows Store is that it doesn't include support for distribution of traditional desktop applications -- you're only able to download Universal Windows Platform (UWP) apps. However, Microsoft is making some changes, and now thanks to Desktop Bridge, we're slowly starting to see desktop apps and tools available in the Store.

 

What's Desktop Bridge?

It's all part of an initiative called Project Centennial, which now you know as Desktop Bridge. The new approach is essentially a "bridge" that let developers take traditional desktop applications and convert them into Universal Windows Platform (modern) apps.

The idea behind Desktop Bridge is that great apps take time and effort, and if they're already working, Microsoft doesn't want you to abandon that code. With Desktop Bridge, you can take your existing desktop application (Win32, WPF, and Windows Forms), make a little modification (if necessary), and bring that great code to the new platform, which can also take advantage of many new features.

The conversion is done using the DesktopAppConverter, which is a tool to automate the process (or at least most of it) to bring your desktop application built using .NET 4.6.1 or Win32 technologies to the new Universal Windows Platform (UWP). In addition, you can also publish the app in the Windows Store to reach millions of new customers, which is one of the reasons Microsoft wants you to convert your app.

 

How does Desktop Bridge works?

When converting an app, the tool runs the app installer inside of an isolated environment that uses a clean Windows 10 image. You can think of it as a lightweight virtual machine, which is used to capture file system I/O and registry keys generated by the desktop installer. Once the app is converted, you'll end up with an APPX package that you can quickly deploy to any computer running the 64-bit (x64) version of Windows 10 using a simple PowerShell cmdlet.

While Desktop Bridge is meant for developers, anyone (who is up to the challenge) can use the new tools and convert virtually any desktop application into a Windows Store app. This is because you don't need the source code — you only need the installer (the .exe file).

Things you need before converting an app

You'll need a computer running the Windows 10 Anniversary Update (build 14393 or later). Your computer must have a 64-bit processor, hardware-assisted virtualization, and Second Level Address Translation (SLAT).

It's important to note that you can only run the DesktopAppConverter on Windows 10 Pro or Enterprise. You can only convert applications with installers, and not portable apps. And you can only deploy converted apps to 64-bit machines.

Finally, you'll also need around 20GB of hard drive space, as the base image, developer tools, and the creation of the isolated environment will take several gigabytes. If you don't have enough storage, the process will fail, and it could take a lot of time to start over.

 

How to prepare your computer to convert apps

Once you have the required hardware and the latest version of Windows 10 running on your computer, you'll need to install and configure a few components.

Important: As usual, here is a friendly reminder to create a full backup of your system, which you can use in case something goes wrong and you need to roll back. This is a task also recommended for anyone who is not a developer but wants to try Desktop Bridge.

 

How to add Containers to Windows 10

While running the setup should install the Containers feature on Windows 10 automatically, there is a chance that this may not happen, as such you can enable this feature in advanced.

To add Containers, do the following:
  1. Open Control Panel.
  2. Click on Programs.
  3. Click on Turn Windows Features on or off.
  4. Check the Containers option.

 
  1. Click OK.
  2. Click Restart to complete the task.

 

How to install the Windows 10 SDK

You'll also need to have installed the Windows Software Development Kit (SDK) on your Windows 10 device, which you can easily do with the following steps:
  1. Download the Windows 10 SDK installer from the Microsoft support website.
  2. Double-click the installer.
  3. Leave the default location and click Next.



  • Decide whether to participate in the Microsoft data collection program and click Next.
  • Click Accept to get through the legal stuff.
  • Make sure all the components are checked and click Install.
 

  • Click Close to complete the task.
Roughly 2.3GB of files will be downloaded at this point, so it might take a while depending on the speed of your internet connection. 

How to install and setup the converter and base image

After checking the minimum system requirements and installing the necessary components, it's now time to install and configure the DesktopAppConverter and the base image.

Note: The commands used in this guide to run Desktop Bridge should work on Command Prompt as well as on PowerShell. However, the tool has been designed to work on PowerShell, so to avoid problems you'll be better off using PowerShell.
  1. Download the DesktopAppConverter from the Windows Store.
  2. On the Store, click the Install button to get the app.
  3. Once the DesktopAppConverter installs, do not launch the app, just close the Windows Store and continue with the steps below.
  4. Visit the Microsoft Download Center to grab the latest Desktop App Converter base image.
  5. Click the red Download button.



  • Select the .wim file with build number that matches the version of Windows 10 you have installed on your PC. For example, BaseImage-14393.wim, if you're running Windows 10 build 14393.
  • Click Next on the support page to begin the download.


If you don't know your current Windows 10 version number, use the Windows key + R keyboard shortcut, type the winver command on Run, and click OK.


  • Open the Start menu and do a search for PowerShell.
  • Right-click the app and select Run as administrator.
  • Type the following command and press Enter:
    Set-ExecutionPolicy bypass
  • Enter the letter A and press Enter to continue.

Now it's the time to set up Desktop Bridge with the base image, and to do that type the following command:

DesktopAppConverter.exe -Setup -BaseImage C:\PATH-TO-IMAGE\BaseImage-1XXXX.wim -Verbose

Important: You must change "XXXX" on the name of the base image to the number of the image you downloaded and remember to specify the path to the location of the image. For example:  

DesktopAppConverter.exe -Setup -BaseImage C:\Users\admin\Downloads\BaseImage-14393.wim -Verbose.

The below image shows an example of the complete command.


  • Restart your computer if prompted. Then PowerShell will open automatically to complete the setup after the reboot by expanding the image to prep the isolated environment.
Once the setup completes, you'll end up in the root directory of the DesktopAppConverter. In my experience, it works better if you continue with next set of instructions while in the root directory of the converter. At least for the purpose of this guide, leave PowerShell open and continue with the instructions below.

 

How to convert desktop apps to Windows Store apps

Congratulations! You made it this far, and now it's the time to have fun. After setting up the converter, you can proceed to convert your traditional desktop app into a Universal Windows Platform app.

For this guide, I chose to convert the popular Notepad++ desktop app, which you can always download and use from the official site. Of course, you can always try to use your own application or another installer.
Quick Tip: It's important to download the app installer in its own folder, as the converter will copy all the files from that location to the isolated environment.

To convert a desktop app into a modern app, do the following:
  1. If you don't have PowerShell already open, bring up the Start menu and do a search for PowerShell.
  2. Right-click the app and select Run as administrator.
  3. Type the following command and press Enter to convert the app:
    DesktopAppConverter.exe -Installer C:\APP-INSTALLER-PATH\APP-NAME.exe -InstallerArguments "/S" -Destination C:\APP-CONVERSION-OUTPUT\APP-NAME -PackageName "APP-NAME" -Publisher "CN=PUBLISHER-NAME" -Version 0.0.0.1 -MakeAppx -Verbose

With this command we're invoking the DesktopAppConverter and passing several arguments. The -Installer switch is used to note the location of the installer. The InstallerAgument "/S" allows to run the installer in silent mode inside the isolated environment, which let the converter record the install process without user interaction.

Then the -Destination switch notes the location the converter will output the final project files. And the rest of the parameters will define the identity of the app, such as package and publisher name, and version number.

Remember that you must update the command line with the appropriate information for your application and paths. Here's an example:  

DesktopAppConverter.exe -Installer C:\Users\admin\Downloads\npp.7.Installer.exe -InstallerArguments "/S" -Destination C:\Users\admin\Downloads\NotepadPlus -PackageName "NotepadPlus" -Publisher "CN=NotepadPlus" -Version 0.0.0.1 -MakeAppx -Verbose

The DesktopAppConverter will then kick in and begin the conversion process, which can take a while depending on your system.

 

How to install a converted app on Windows 10

Once the process completes without any red flags, you'll end up with a project folder that contains a file with a .appx extension.

The final step will be to install the converted app on your computer and to do this you'll need to use PowerShell.

To install an APPX application on Windows 10, do the following:
  1. Open Start menu and do a search for PowerShell.
  2. Right-click the app and select Run as administrator.
  3. Type the following command and press Enter to convert the app:
    Add-AppxPackage -Path PATH-TO-APPXFILE\AppxManifest.xml -Register






Remember to replace "PATH-TO-APPFILE" for the path of your AppxManifest.xml file, whic is inside of the ProgramFiles folder, inside the project output folder. For example, Add-AppxPackage -Path C:\Users\Admin\Downloads\App\PrograFiles\AppxManifest.xml -Register.

At this point, PowerShell should install the converted modern app on your computer. You can then launch the app like with any other app from the Start menu -- it'll even show up in the Recently Added list.


Wrapping things up

It's worth pointing out that after converting and installing, the app will run on your computer like any other app. However, for developers at least, this is just the beginning. If you want to take advantage of the new platform fully, you still have to customize other aspects of the app, such as some visual elements like the app icon, sign the package, and incorporate other specific features available in the new app model like notifications, Live Tiles, Action Center, and more.

Post a Comment

 
TECH SUPPORT © 2012-2016