Given a PreProcessor definition like the following:
<PreprocessorDefinitions>%(PreprocessorDefinitions);ENABLE_DEBUGGING=1;</PreProcessorDefinitions>
Is it possible to determine the value of ENABLE_DEBUGGING during an MSBuild post-build event?
Given a PreProcessor definition like the following:
<PreprocessorDefinitions>%(PreprocessorDefinitions);ENABLE_DEBUGGING=1;</PreProcessorDefinitions>
Is it possible to determine the value of ENABLE_DEBUGGING during an MSBuild post-build event?
Here's one of the probably multiple ways to do this; will only work if the ClCompile ItemGroup contains items, in other words when there are files to compile, and if they all have the same value for PreprocessorDefinitions; it stores the number found after the ENABLE_DEBUGGING=
string in the DebugVal property.:
<Target Name="CheckValue" BeforeTargets="BuildGenerateSources">
<PropertyGroup>
<PreProc>%(ClCompile.PreprocessorDefinitions)</PreProc>
<DebugVal>$([System.Text.RegularExpressions.Regex]::Match( $(PreProc), 'ENABLE_DEBUGGING=(\d)' ).Groups[ 1 ].Value )</DebugVal>
</PropertyGroup>
<Message Text="ENABLE_DEBUGGING = $(DebugVal)" />
</Target>