Using Visual C++ Runtime in Centennial project
Last update: 11/22/2017
During Build 2015, we announced the Desktop Bridge (formerly called Project Centennial) to bring your desktop apps to UWP. With the Desktop App Converter, you can package your desktop application as an appx package that can be deployed to a Windows 10 Desktop. See this link to learn more about the Desktop Bridge. If you want to convert your C++ desktop application (win32, MFC, etc.) you have to handle deployment of VC++ runtimes, such as vcruntime140.dll, as you always do for C/C++ applications.
We have created support for Visual C++ Runtime in this context for the version 11.0, 12.0 and 14.0 of the VC++ Runtime. Centralized deployment of the VC++ runtime DLLs through the Windows Store. This Runtime is the Desktop Visual C++ libs for CRT, STL, ConCRT, MFC, ATL and C++ amp. These serviced versions of the VC++ runtime are available on the Windows Download center:
- VC 14.0 framework packages for Desktop Bridge
- VC 12.0 framework packages for Desktop Bridge
- VC 11.0 framework packages for Desktop Bridge
For your applications, we have created framework packages with the desktop libraries for the VC++ 14.0 (VS2015 and VS2017), VC++ 12.0 (VS2013) and VC++ 11.0 (VS2011) versions of the C++ Runtime. This installer will place the framework packages under the Extension SDKs folder: %PROGRAMFILES(X86)%\Microsoft SDKs\Windows Kits\10\ExtensionSDKs
We have created framework packages that will contain all the Visual C++ Runtime components for the following targets: X86, x64 for debug and release.
Visual Studio 2017 support:
As Visual Studio 2017 (dev15) generate compatible binaries with those generated by Visual Studio 2015(dev14), you should reference the “VC 14.0 framework packages for Desktop Bridge” inside the manifest (see below how to do that manually).
In the version 15.4 of Visual Studio 2017, we introduced the new Windows Application Packaging project to help you modernizing your application by using the new Windows 10 App Deployment Stack (See this post). We highly recommend to use this version to package your application as all the manifest manipulation is now automatized.
Referencing manually the VC Runtime framework packages from converted desktop apps:
1. First, ensure you are set up to use Desktop Bridge (Centennial). For instructions, see Desktop App Converter Preview (Project Centennial).
2. Run the converter and then installer for your Win32 application. The converter captures the layout, and any changes made to the registry and outputs an Appx with manifest.
3. In the Appx layout, update the AppxManifest.xml to contain a reference to the VCLibs UWPDesktop framework package by adding the <PackageDependency> element under the <Dependencies> element:
<PackageDependency Name=”Microsoft.VCLibs.140.00.UWPDesktop” MinVersion=”14.0.24217.0″ Publisher=”CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US” />
Also, please remove any C++ Runtime dlls from the appx layout. Consuming the runtime via framework packages is the recommended approach.
Note: Starting with Desktop App Converter v0.1.23, converter will auto detect VCLibs dependency and add the PackageDependency entry in the AppxManifest.xml. It will also remove any local copies of the C++ runtime dlls.
4. Install the VCLibs UWPDesktop framework package corresponding to the configuration and architecture you are targeting, using add-appxpackage cmdlet.
For instance, if your application is targeting x86 Retail config, open powershell:
a. Goto %PROGRAMFILES(X86)%\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs.Desktop\14.0\Appx\Retail\x86
b. Add-appxpackage Microsoft.VCLibs.x86.14.00.Desktop.appx
5. Deploy your application using the add-appxpackage –register AppxManifest.xml cmdlet or by repackaging it using MakeAppx, see App packager (MakeAppx.exe).
Note: You could install these framework using DependencyPath parameter from the Add-AppxPackage command. See here for more detail on this option
To deploy a debug version of the application, add a PackageDependency to the Debug framework package, Microsoft.VCLibs.140.00.Debug.UWPDesktop:
<PackageDependency Name=”Microsoft.VCLibs.140.00.Debug.UWPDesktop” MinVersion=”14.0.24217.0″ Publisher=”CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US” />
Universal CRT (uCRT) is installed in system32 as part of the Windows 10 OS (just like user32.dll), but if you want the debug version of uCRT, you need to install it. You can find the debug version in the Windows 10 SDK (use the same version used to create the app)
In case the target computer doesn’t have the uCRT debug version, you have to package the Debug uCRT app locally. To do this, copy the ucrtbased.dll from C:\Program Files (x86)\Windows Kits\10\bin\<arch>\ucrtbased.dll next to the executable.
VC++ 12.0 support:
The framework packages for VC12.0(Visual studio 2013) are installed under: %PROGRAMFILES(X86)%\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs.Desktop.120\
To reference the 120 framework package, add the following line to the AppxManifest.xml:
<PackageDependency Name=”Microsoft.VCLibs.120.00.UWPDesktop” MinVersion=”12.0.40653.0″ Publisher=”CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US” />
Change the PackageDependency Name to Microsoft.VCLibs.120.00.Debug.UWPDesktop to deploy the debug version.
Note that the existing VC++ 12.0 libraries created during the Windows 8 timeframe have runtime checks to determine whether the app is running under the app container or not. When running desktop apps as a packaged app, these checks might limit the functionality of the desktop app or cause it to behave like a UWA (Universal Windows Application) (limited file system access or create thread initializing MTA etc.). We have fixed this behavior in the VC++ libraries contained in these framework packages and thus removing the modern app limitations from your desktop applications.
We look forward to your feedback! As always, we can be reached via the comments below, via email (firstname.lastname@example.org) and you can provide feedback via Help > Report A Problem in the product, or via Developer Community. You can also find us on Twitter (@VisualC) and Facebook (msftvisualcpp).
 Under Windows 10 SDK License