In the previous post we’ve learned how to convert the installer of a traditional desktop application (based on Win32 technologies like the .NET Framework, C, Delphi, etc.) in an AppX package, so that we can start to leverage the best of both worlds: the maturity of the Win32 frameworks and the better security and deployment model offered by the Universal Windows Platform.
In some cases, it may happen that your application leverages some native code or that has a dependency from a component written in C / C++ and, as such, to run properly, it requires that the final user has installed the Visual C++ libraries on his system. Many traditional installers takes care of this, by offering to the user to download and install them if they aren’t available in Windows.
How is this requirement managed for converted applications? First, to understand if you are in such a scenario, it’s enough to keep an eye on the output of the Desktop App Converter at the end of the conversion process. If your application has such a dependency, you will see a message like the following one:
"Warning Summary: W_PACKAGE_DEPENDENCY_ADDED a dependency on framework package 'Microsoft.VCLibs.140.00.UWPDesktop' was added to the AppxManifest.xml. See 'http://go.microsoft.com/fwlink/?LinkId=821959' for guidance on installing the package prior to local deployment. Otherwise, if th is is in error, remove the corresponding entry from Dependencies in the AppxManifest.xml before packaging and deploying your application. "
The message is quite self-explanatory: the Desktop App Converter has found a dependency from the version 14.0 of the VC libraries (which is required to run native components) and, as such, has modified the manifest file in order to support this requirement. You can easily notice this by opening the AppxManifest.xml file which is included in the PackageFiles folder created by the tool. In fact, under the Dependencies section, you will find the following entries:
<Dependencies> <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" /> <PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="12.0.40652.5" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" /> </Dependencies>
As you can notice, other than the standard dependency from the 14393 SDK of the Universal Windows Platform, you will find a new dependency from a package which name is Microsoft.VCLibs.140.00.UWPDesktop and published by Microsoft.
The problem is that if, right now, you would try to install the AppX you’ve just generated you will get an error, since the package isn’t able to find all the required dependencies. The reason is that, by default, the UWP version of the Visual C/C++ libraries used by the Desktop Bridge aren’t installed in Windows 10 Anniversary Update. The output message displayed by the Desktop App Converter, in fact, invites you to visit the following page: https://blogs.msdn.microsoft.com/vcblog/2016/07/07/using-visual-c-runtime-in-centennial-project/ It’s a blog post from the Visual Studio team, which explains how these dependencies are handled but, especially, it provides a link to download the different UWP libraries, based on the various available versions of the VC ones:
- VC 14.0 framework packages for Desktop Bridge
- VC 12.0 framework packages for Desktop Bridge
- VC 11.0 framework packages for Desktop Bridge
You will need to download the proper version based on the warning message that was displayed by the Desktop App Converter at the end of the conversion process and on the dependency that was added in the manifest file. For example, in the previous scenario, the tool has added a dependency to a library called Microsoft.VCLibs.140.00.UWPDesktop, as such you will need to download the VC 14.0 framework package (the first of the three links of the list).
Regardless of the version you have downloaded and installed, the setup process will create a folder inside the path C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\ for each version of the library. For example, if you have installed the 14.0 version, you will find the UWP version you need in the path C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs.Desktop\14.0\Appx\Retail
Inside the folder you will find a version of the library for each architecture: in our case, we are interested only in the x86 and x64 versions, since desktop apps converted using the Desktop Bridge can’t be executed on devices based on the ARM architecture (like phones or a Raspberry Pi). Consequently, open both the x64 and x86 folders, where you will find an AppX file with a name like Microsoft.VCLibs.x86.14.00.Desktop.appx (of course, instead of 14.00 you could find 12.00 or 11.00 as release numbers, based on the VC version used by your app). Double click on the AppX and proceed with the installation, like if it’s a normal application:
The only difference is that, at the end of the installation, when you’ll be prompted to Launch the application, don’t do it, because it won’t have any effect: we’re talking about libraries and not a real application that can be executed in a traditional way. Under the hood, however, the procedure will have installed the dependencies that were required bye the original app you have converted: consequently, you will now be able to try again to install the original AppX and, this time, the operation will complete just fine.
Important! This procedure is required only in case of testing or manual deployment of your converted application, which means that you’re going to manually install the AppX package on your PC or someone else’s one. In case your app is distributed through the Store, you won’t have to deal with this requirement: the Store, in fact, will take care automatically of solving the dependency and installing the proper version of the library if needed, together with the real application.