MSVC 2015 Universal CRT for app-local deployment - c++

It was announced that the Universal CRT would be a re-distributable DLL such that app-local deployment would still be possible.
I have installed the Visual Studio 2015 Express Edition and I was looking for ucrtbase.dll in the SDK directories, but I could not find anything. The directory that I looked into was "C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10", but that only has the debug version of the CRT under "Microsoft.UniversalCRT.Debug".
I prefer not to copy any DLLs from my system, I always only package files from the "Redist" directories. So for instance (like with the previous versions of MSVC), I re-distribute files from "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT" with x86 builds of my app.
Is there a package that I can download that contains the ucrtbase.dll, or perhaps a Visual Studio or SDK update?
Also I am not sure at this point whether just the ucrtbase.dll will be sufficient, as the applications seem to be linked to the stub DLLs api-*.dll, and I'm not sure whether those need to be re-distributed as well.

This blog post under Distributing Software that uses the Universal CRT section describes all the cases in detail, with a big red update notice concerning app-local deployment:
Updated September 11, 2015: App-local deployment of the Universal CRT is supported. To obtain the binaries for app-local deployment, install the Windows Software Development Kit (SDK) for Windows 10. The binaries will be installed to C:\Program Files (x86)\Windows Kits\10\Redist\ucrt. You will need to copy all of the DLLs with your app (note that the set of DLLs are necessary is different on different versions of Windows, so you must include all of the DLLs in order for your program to run on all supported versions of Windows)

You can download UCRT from Microsoft Donwload Center. UCRT is part of OS now, for Vista SP2/7/8/8.1 it is distributed by Update Center.

Related

Different C++ Redistributable DLL's for VS 2013 and VS 2015

I built my application using VS 2013, and delivered two DLLs:
msvcp120.dll
msvcr120.dll
Building the same application using VS 2015, instead we need:
msvcp140.dll
vcruntime140.dll
Is vcruntime140.dll replacing the former msvcp120.dll?
Yes.
Visual Studio usually breaks binary compatibility with older releases when it gets a major version update. The one notable exception is the transition from VS2015(14.x) to VS2017(15.x), which did not break binary compatibility.
For all other releases, when you change the version of Visual Studio, you'll need to change which Runtime Redistributables get installed onto the target computer.
EDIT: Per Christopher's observation: Don't manually install the .DLL files onto the target computer. Download the Redistributable Installer from Microsoft, and ship that with your program, with instructions (or an installer) that installs that first. This link goes to the 2015 version, but you should grab whichever version corresponds to the specific version of visual studio that you are using.

Can I bundle the Visual Studio 2015 C++ Redistributable DLL's with my application?

I've built a C++ application using Microsoft Visual Studio 2015 Community Edition. I'm using Advanced Installer to make sure that the Visual C++ Redistributable for Visual Studio 2015 is a prerequisite.
However, the redistributable's installer isn't perfect. Some of my users have reported that the redistributable installer hangs, or it fails to install when it says it does, and then users get the "This program can't start because MSVCP140.dll is missing from your computer" error.
According to Microsoft, I can now package the redistributable DLLs along with my application, though they don't recommend it (1, 2):
To deploy redistributable Visual C++ files, you can use the Visual C++ Redistributable Packages (VCRedist_x86.exe, VCRedist_x64.exe, or VCRedist_arm.exe) that are included in Visual Studio. ... It's also possible to directly install redistributable Visual C++ DLLs in the application local folder, which is the folder that contains your executable application file. For servicing reasons, we do not recommend that you use this installation location.
There are 4 files in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x64\Microsoft.VC140.CRT. Does that mean I just need to copy them to my application's directory during the install process?
MyApp.exe
concrt140.dll
msvcp140.dll
vccorlib140.dll
vcruntime140.dll
Is this OK to do? Do I need to show a license? Why aren't more people doing this instead of requiring yet another preinstall of the redistributable?
There are 4 files in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x64\Microsoft.VC140.CRT. Does that mean I just need to copy them to my application's directory during the install process?
Yes, and the paragraph you quoted means just that.
Is this OK to do? Do I need to show a license? Why aren't more people doing this instead of requiring yet another preinstall of the redistributable?
Technically, that's OK to do. If you want to be pedantic about it, you may include a note in the readme or help/about to the effect that VC++ 2015 redistributables provided in "local deployment" mode as explicitly allowed by Microsoft's Deployment in Visual C++ (with more links to the file lists and licenses at Redistributing Visual C++ Files).
As to why more people don't do it, I'd guess that (among those who care at all):
for a single module app like MyApp.exe it's easier to build it with everything linked statically as to eliminate external dependencies to begin with;
not including those files saves 1+ MB from the distribution (presumably download) size;
running with private copies of the runtime ("local deployment") shifts the responsibility of updates to the maintainer, so that in case of a critical/security fix the package would have to be reissued timely - as opposed to "central deployment" where it would likely be delivered via Windows Update, with both the good and bad that may bring.
If you have problems with the prerequisites installer you also have the option to install the redistributables as merge modules. As the same MSDN article mentions:
Another option is to use redistributable merge modules (.msm files), which can be found in Program Files [(x86)]\Common Files\Merge Modules.
Using merge modules it is a much cleaner option than manually adding the files. The files can be deleted accidentally by another colleague which does not know why they are there, or one of them might not get installed, etc...
All editions of Advanced Installer have support to include merge modules, including the free edition.
how to add a merge module into an Advanced Installer project/package
Visual Studio Community 2022
Go to: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.32.31326\x64\Microsoft.VC143.CRT
Copy the contents into the search path of your project

How to distribute VC redist with an MSI when using Visual Studio 2015?

We are just switching to Visual Studio 2015, but we have found a problem in deployment of our application.
We use Wix/MSI for deployment and until now we were using merge modules for distribution of VC redist.
But now we have a problem that our application requires ucrtbase.dll. There is a new Universal CRT according to this article and it is not contained in any merge module.
In above-mentioned article they are saying that:
There will not be a merge module for the Universal CRT. If you currently use the CRT merge modules and still want to deploy the Visual C++ libraries centrally, we recommend that you move to the above mentioned Windows Update package or to the VCRedist. Alternatively, you may choose to link statically to the Universal CRT and the Visual C++ libraries
Does this mean that we cannot distribute C++ runtime with our MSI as it cannot run executables (VCRedist.exe)? Or is there a way to compile our project in Visual Studio 2015 so it will not require this Universal CRT?
Thank you in advance.
If you use WiX, you could switch to Burn and run the VC Redist packages as part of the setup.
The article you referenced also says that app-local deployment of the Dlls is supported, so you could install the appropriate Dlls without needing redist.
I would use Burn to install the official redist - it's the only way that Mocrosoft can service those Dlls if there are issues. If you use app-local or your own copies of the Dlls you may need to ship patches or upgrades if there are security issues in those Dlls.

Visual C++ 2015 redistributable DLLs for app-local deployment

Up to Visual Studio 2013 all you needed was msvcr[version].dll and msvcp[version].dll.
Now they changed the DLLs with 2015.
What do I need to include in order to avoid a redist installer?
EDIT:
It seems to be impossible now:
http://blogs.msdn.com/b/vcblog/archive/2015/03/03/introducing-the-universal-crt.aspx
"App-local deployment of the Universal CRT is not supported."
UPDATE:
The content of the link above was updated on 11 Sep 2015. Now it's possible to make app-local deployment.
This worked for me (x86 app).
Shipping all dlls from these locations with your app:
C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT
Myself, I needed an additional file to make this happen. Here are the directories, with one in a more generic format:
Copy all the files from "C:\Program Files\Windows Kits\10\Redist\ucrt\DLLs\x86" or "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86" (or copy them from the x64 directory if it's a 64-bit app).
Copy msvcp140.dll and vcruntime140.dll from:
<Visual Studio 2015 Install Directory>\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT (or copy them from the x64 directory if it's a 64-bit app).
If you're using Qt, copy these files into the directory made by windeployqt.
In general, I found that you can just do step #1, and attempt to run your app. It will tell you the first of the files it is missing, and once you have put it in your app's directory, it will tell you the next one you need. In my case, it was two. Copying similar files from my <Windows>\System32 folder, e.g., was not successful. I have found using Dependency Walker and trying to satisfy the dependencies it indicates to be unsuccessful.
This allows you to make a portable app that will run on M$ OS's as old as XP; or install for users without vcredist_x86 or vcredist_x64, who don't have admin privileges.
BTW: Step #1 is pretty official. Here it is at the MSDN blog: Introducing the Universal CRT They say to copy them all for an app to run on all M$ OS's.
In general, you can use dependency walker to find the list of dependent dlls.
Regarding the visual studio runtime dlls, what you are mostly concerned about are the dlls with Visual studio specific versions in them.
As mentioned at point 6) of this article now it's possible to make local deployment of the Universal CRT. To do that you should install Windows 10 SDK and copy all the binaries from C:\Program Files (x86)\Windows Kits\10\Redist\ucrt.

Use specific version of vcredist?

Is it possible in Visual Studio 2008 SP1 to target a C++ COM project to vcredist 2008 instead of vcredist 2008 SP1?
Our customers have the vcredist 2008 installed and we don't want to force them to install vcredist 2008 SP1. (thousands of computers!)
VS2008 actually, by default, continues to target the VS9 RTM redist.
What is happening in dependency checker is, when VS9 SP1 is installed, a policy file is also installed that redirects attempts to load the RTM redistributables to the SP1 redistributables.
In order to get VS9 SP1 to actually require the SP1 runtimes you need to add the following macro to your project settings or precompiled header:
#define _BIND_TO_CURRENT_CRT_VERSION 1
You can try to remove the embed manifest (look under the project settings Manifest Tool) and provide your own manifest for the application that targets the pre sp1 CRuntime versions.
You can also deploy the C-Runtime yourself, in the redist folder under x86/x64 you will find the folder of the C-Runtime (Microsoft.VC90.CRT) just copy those folders in the same folder as your exe.
Use the static C-Runtime option, so that the C-Runtime will be used as static lib, its useful if you don't have a lot of dll/exe.