Can I set a compiler option using MSBuild command line? - c++

I want to, for example, enable showing includes (\showIncludes from C++ compiler Advanced configurations) for some project via MSbuild command line. Can I make it somehow without changing the project properties?
The following command line I tried doesn't work:
MSBuild.exe /p:Configuration=Debug /p:Platform=x64 /p:ShowIncludes=true "myproj.vcxproj" -t:Rebuild

Yes, here are docs. You need to pass /showIncludes:
MSBuild.exe /p:Configuration=Debug /p:Platform=x64 /showIncludes "myproj.vcxproj" -t:Rebuild
Example

Related

how to disable /Qspectre using Visual Studio 2019 Developer Command Prompt

I tried to google it but couldn't find it. I want to Disable /Qspectre from command line.
Note: I am trying this inside docker container i have already
installed component for it.But still i am getting error MSB8040:
Spectre-mitigated libraries are required for this project.So i want to
disable it and give try. if it works.
docker run -v C:\BuildTools\ConsoleApplication1:C:\ConsoleApplication1 --name CP3 buildtools2019 msbuild C:\ConsoleApplication1\ConsoleApplication1.sln -maxcpucount:3 /p:Configuration=Debug /p:Platform=x64
This is PowerShell command which i am using it to run my project. open for all suggestion and recommendation.
I am afraid there is no direct command line method to disable /Qspectre. I suggest that you could disable it by some other methods.
Put/copy file with name 'Directory.Build.props' to build folder with content:
<Project>
<PropertyGroup Label="Configuration">
<SpectreMitigation>false</SpectreMitigation>
</PropertyGroup>
</Project>
That overrides default VS behavior and disables /QSpectre compiler switch.
You could refer to this link.

MSBuild: error MSB4126: The specified solution configuration "Release|AnyCPU" is invalid

I am stumping my head on this. I am trying to build libconfig on Windows - an OS that I am very unfamiliary with. I have installed the MSBuild Tools. I am able to compile CMake projects by using the NMake Generator and then compiling the resulting Makefile. libconfig has a .libconfig_vs2017.sln, which seems to be a "solution" file for the version of MSBuild I have installed.
Before compiling I have ran "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Auxiliary/Build/vcvars64.bat" because otherwise none of the necessary tools appear to be in the path.
No matter which combination I try, I always keep getting an error that the specified solution configuration is invalid. I have tried the following options:
msbuild libconfig_vs2017.sln
msbuild libconfig_vs2017.sln /p:Configuration=Debug /p:Platform="Any CPU"
msbuild libconfig_vs2017.sln /p:Configuration=Release /p:Platform="Any CPU"
msbuild libconfig_vs2017.sln /p:Configuration=Debug /p:Platform="x64"
msbuild libconfig_vs2017.sln /p:Configuration=Release /p:Platform="x64"
msbuild libconfig_vs2017.sln /p:Configuration=Debug /p:Platform="x86"
msbuild libconfig_vs2017.sln /p:Configuration=Release /p:Platform="x86"
What am I missing here to get this thing to compile on Windows? I am considering installing autotools but given that there is a supposedly ready to use solution file that seems overkill (and is probably difficult on Windows in its own right).

How can I build all configurations with MSBuild VS2015 from the command line?

In previous versions of MSBUILD you can build all configurations in a solution using the following command line arguments:
msbuild /t:BuildAll /Configuration:"Debug;Release;ContinuousIntegration"
as shown here
However this does not work with MSBUILD VS2015 and gives the following error:
MSBUILD : error MSB1006: Property is not valid.
Switch: Release
This is a similar question to the one here however I am not using cmake just simply straight MSBUILD
For example:
C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe"Uninstaller.vcxproj /property:Configuration=Release'
Sometimes you need run this for setting environment
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat"'

setting VCCLCompilerTool.TreatWChar_tAsBuiltInType property on MSBuild command line

I need to build Visual Studio 2010 projects with wchar_t not being native type. The IDE setting should be equal to the value of VCCLCompilerTool.TreatWChar_tAsBuiltInType property. However trying to set it using /p:VCCLCompilerTool.TreatWChar_tAsBuiltInType=false on MSBuild command seems to fail. Is there any other way how I could achieve this from the MSBuild command line?
You have to set environment variable CL to /Zc:wchar_t-
Example batch file to compile with forced /Zc:wchar_t-:
set CL=/Zc:wchar_t-
%windir\Microsoft.NET\Framework\v4.0.30319\msbuild.exe projectName.vcxproj /t:Rebuild

How to configure Include/Lib directories of VC++ devenv.com command line?

I'm building a VC++ 9.0 project from command line (using devenv.com):
devenv.com myproject.sln /Build "Release|Win32"
I need to add additional include path to it. How can I do this?
I gave up using devenv.com for the same reason. I use msbuild instead.
Add your include and lib to your project
launch vcvarsall.bat
call msbuild.exe
I have Visual Studio 2010. I created a small batch file that is in my path (because I have many dev environments on my computer).
#c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat %*
And I actually wrap msbuild.exe with this simple batch file :
#for %%i in (*.sln) do #msbuild %%i /v:m /nologo %*
With the trailing %*, you can add other parameters when needed.