Reputation: 9442
How can I pass the annoying /Zm500
(500% virtual memory, because MS compiler is to stupid and even 32bit) through "msbuild.exe" such that when compiling a solution with it uses this option for every "cl.exe" invocation?
Upvotes: 1
Views: 1663
Reputation: 76910
How can I pass the annoying /Zm500 through "msbuild.exe"
We could not pass the global option /Zm via the MSBuild command line directly. Because the PreprocessorDefinitions
of CLCompile
, which is not a PropertyGroup
.
<ClCompile>
<AdditionalOptions>/bigobj /Zm500 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
</ClCompile>
As a workaround for this question, you can add a target invoke MSBuild to pass an external parameter into the project file by MSBuild command line:
First, change the fixed values of “/Zm500” with $(Zm) in the project file:
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalOptions>/bigobj $(Zm) %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
</ClCompile>
Second, add a target in to the project file:
<Target Name="TestBuild" Returns="@(ManagedTargetPath)">
<MSBuild Projects="YourProjectName.xxproj" Targets="NormalBuild" Properties="Zm=/Zm500"/>
</Target>
Third, use the MSBuild command line with the properties /Zm:
msbuild.exe "$(ProjectPath)\.xxproj" /p:Zm=/Zm500
Upvotes: 2