How to Convert Desktop Apps to Universal Windows Platform Apps with Desktop Bridge
Total Page:16
File Type:pdf, Size:1020Kb
How to convert desktop 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. 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? How does Desktop Bridge works? Things you need before converting an app How to prepare your computer to convert apps How to convert desktop apps into Windows Store apps How to install a converted app on Windows 10 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 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). In this Windows 10 guide, we'll walk you through the steps to convert a traditional desktop application into a Universal Windows Platform app. Things you need before converting an app You'll need a computer running the Windows 10 Anniversary Update (build 1607-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 download a free version on the Microsoft site as trail. 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. 5. Click OK. 6. 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. 4. Decide whether to participate in the Microsoft data collection program and click Next. 5. Click Accept to get through the legal stuff. 6. Make sure all the components are checked and click Install. 7. 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 Desktop App Converter 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. 6. 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. 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. 7. Click Next on the support page to begin the download. 8. Open the Start menu and do a search for PowerShell. 9. Right-click the app and select Run as administrator. 10. Type the following command and press Enter: Set-ExecutionPolicy bypass 11. Enter the letter A and press Enter to continue. 12. 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. 13. 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 For this manual, I chose to convert the popular Notepad++ desktop app. 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 ISE already open, bring up the Start menu and do a search for PowerShell, and run as Admin!! 2. Right-click the app and select Run as administrator. 3. Type the following command and press Enter to convert the app: # Path App-Conversion-Output has to exsist. cd c:\ $path = "C:\App-Conversion-Output" If(!(test-path $path)) { New-Item -ItemType Directory -Force -Path $path } DesktopAppConverter.exe -installer C:\APP-INSTALLER-PATH\APP-NAME.exe -installerarguments "/S" - destination c:\App-Conversion-Output -packagename "notepadplus" -publisher "CN=PUBLISHER-NAME" - Version 0.7.5.8 -makeappx -Sign -verbose -Verify 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 InstallerArgument "/S" allows to run the installer in silent mode inside the isolated environment, which let the converter record the install process without user interaction. The -Destination switch notes the location the converter will output the final project files.