The following is taken from a regular VS2010 C++ project.
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
If i edit PreprocessorDefinitions
i can set a definition that is used by the preprocessor. I can see this in my code via #ifdef
etc.
However if i use the following
<Target Name="NormalBuild" Condition=" '$(_InvalidConfigurationWarning)' != 'true' " DependsOnTargets="_DetermineManagedStateFromCL;CustomBeforeBuild;$(BuildDependsOn)" Returns="@(ManagedTargetPath)">
<ItemGroup>
<ManagedTargetPath Include="$(TargetPath)" Condition="'$(ManagedAssembly)' == 'true'" />
</ItemGroup>
<Message Text="PreprocessorDefinitions: $(PreprocessorDefinitions)" Importance="High" />
</Target>
<Target Name="TestBuild" Returns="@(ManagedTargetPath)">
<MSBuild Projects="demo.vcxproj" Targets="NormalBuild" Properties="PreprocessorDefinitions=THISGETSSETBUTDOESNOTHING"/>
</Target>
i can also see via the message that PreprocessorDefinitions
contains the value i set via Properties="PreprocessorDefinitions=THISGETSSETBUTDOESNOTHING"
but i can not control my build using #ifdef
etc.
If i use a regular setup and try to output PreprocessorDefinitions
using <Message Text="PreprocessorDefinitions: $(PreprocessorDefinitions)"
the field is actually blank and does not contain the expected <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
although i can use any one of those keys to control my build using #ifdef
etc.
- Why is that?
- What can i do to pass PreprocessorDefinitions für a VS2010 C++ Project via the tasks
Properties
element?