Reputation: 3657
What's the difference between:
VsDevCmd.bat
(Developer Command Prompt for VS2012)vcvarsall.bat
(VS2012 x86\x64\ARM Native\Cross Tools Command Prompt)I have a pretty good understanding of vcvarsall.bat
as it's been part of Visual Studio for many previous versions. vcvarsall.bat
was basically my goto tool for MsBuild even when building .NET projects even though it's technically part of Visual C++.
What I don't have a good understanding of is VsDevCmd.bat
. It seems to be new with VS2012 and I'm not sure what it's purpose is. I've noticed it's not in the Visual C++ folder like vcvarsall.bat
but it's in the Visual Studio Tools folder.
Should I be doing doing my .NET msbuilds in this tool now? If so how do I setup the same kinds of x64\x86\ARM defaults like the vcvarsall.bat
?
Upvotes: 19
Views: 11454
Reputation: 101
All of these scripts are used for various development activities from the console, not from the IDE. For building, linking, decompiling, etc.
VsDevCmd.bat
applies to the entire Visual Studio environment. Including configuring the C / C++ build environment. It is also for .NET with C# etc. By default, it aims to build from x86 for x86 (this can be changed with arguments passed to this script). It should be noted that there is a PowerShell version of this script.
https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022
vcvarsall.bat
it is mainly used to configure the C / C++ build environment. You can use arguments for this script to change the target and host architectures. This script also relates to scripts where the target and host architectures are already selected and do not need to be passed in the script invocation arguments.
https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170
If you will be doing C / C++ activities it is better to use vcvarsall.bat
. Because this script, according to Microsoft's documentation from the link above and comments from the vcvarsall.bat
file, can change some system variables to configure the build type for C / C++ but not for dot NET.
The difference may arise as you use more different workloads and additional packages.
For example, I have .NET desktop development
and Desktop development with C++
and VS IDE 2022
installed and after running the vcvarsall.bat
script, it additionally adds the Platform
system variable.
At some point, script vcvarsall.bat
finally runs script VsDevCmd.bat
.
I don't know if it will be 100% safe to use VsDevCmd.bat
script to build C / C++. I'm unable to determine when the difference will occur and what will be affected by the additionally set system variables. According to Microsoft's documentation, BAT scripts are generated (adapted) for the functionality installed in Visual Studio.
It's best if someone from Microsoft spoke about this part.
MSBuild, nmake and cmake can be run from both scripts.
related:
Upvotes: 1
Reputation: 506
From my understanding and looking at the various batch scripts in VS 2012:
vcvarsall.bat
called with x86 (or just vcvarsall.bat
with no option, which defaults to x86
) is identical to the VsDevCmd.bat
. The batch file that vcvarsall.bat
calls when passed with the x86
option is
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat
This file is identical to the VsDevCmd.bat
file that is located in
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat
which is what the developer command prompt calls when opened from the start menu.
Thus for more control on the platform it is better to call vcvarsall.bat
with the appropriate option passed: x86
or amd64
or arm
or x86_amd64
or x86_arm
.
Upvotes: 9