Note that there are some explanatory texts on larger screens.

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

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload