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?
Asked
Active
Viewed 1,444 times
1

Gabriel
- 8,990
- 6
- 57
- 101
-
there is also a 64bit cl.exe – stijn Apr 21 '17 at 06:57
-
Possible duplicate of [How to set PreProcessorDefinitions as a task propery for the msbuild task](http://stackoverflow.com/questions/15141429/how-to-set-preprocessordefinitions-as-a-task-propery-for-the-msbuild-task) – stijn Apr 21 '17 at 06:58
1 Answers
2
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

Leo Liu
- 71,098
- 10
- 114
- 135
-
2You *can* do this without modifying the project using one of the extension points, see e.g. http://stackoverflow.com/questions/15141429/how-to-set-preprocessordefinitions-as-a-task-propery-for-the-msbuild-task/17446623#17446623 – stijn Apr 21 '17 at 06:55
-
@stijn, That looks like a very nice way, I will try it later, I have updated my answer, thanks for your sharing. – Leo Liu Apr 21 '17 at 07:08