Do "if" type statements exist when inside Property Groups in MSBuild?

cmd, msbuild, post-build-event, tfsbuild

Solution

You're already using it: `Condition`. You just have to extract an extra step to create a property that will be used as the TEAMBUILD value. For example:

<PropertyGroup Condition='$(BuildingInsideVisualStudio)' != 'true' ">
  <TeamBuildValue>FALSE</TeamBuildValue>
</PropertyGroup>

<PropertyGroup Condition='$(BuildingInsideVisualStudio)' == 'true' ">
  <TeamBuildValue>TRUE</TeamBuildValue>
</PropertyGroup>

<PropertyGroup>
  <PreBuildEvent>
  </PreBuildEvent>
  <PostBuildEvent>
    ...
    set TEAMBUILD=$(TeamBuildValue)
    ...
  </PostBuildEvent>
</PropertyGroup>

Problem

I currently have to have two separate property groups with only two differences between them, that are set to have one or the other trigger depending on a condition. Here's what I have: ``` <!--CAME FROM TEAMBUILD--> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' != 'Debug|AnyCPU' AND '$(Configuration)|$(Platform)' != 'Release|AnyCPU' AND '$(BuildingInsideVisualStudio)' != 'true' "> <PreBuildEvent> </PreBuildEvent> <PostBuildEvent> set MAGE="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\mage.exe" set APPFILE=$(TargetDir)$(TargetName).application set MANIFEST=$(TargetPath).manifest set CERT=$(ProjectDir)$(TargetName).pfx set PROJECTNAME=$(TargetName) set CONFIGURATION=$(ConfigurationName) set TARGETDIR=$(TargetDir) set TEAMBUILD=$True Powershell -File "$(ProjectDir)POSTBUILD.ps1" </PostBuildEvent> </PropertyGroup> <!--CAME FROM PUBLISH COMMAND--> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' != 'Debug|AnyCPU' AND '$(Configuration)|$(Platform)' != 'Release|AnyCPU' AND '$(BuildingInsideVisualStudio)' == 'true' "> <PreBuildEvent> </PreBuildEvent> <PostBuildEvent> set MAGE="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\mage.exe" set APPFILE=$(TargetDir)$(TargetName).application set MANIFEST=$(TargetPath).manifest set CERT=$(ProjectDir)$(TargetName).pfx set PROJECTNAME=$(TargetName) set CONFIGURATION=$(ConfigurationName) set TARGETDIR=$(TargetDir) set TEAMBUILD=$False Powershell -File "$(ProjectDir)POSTBUILD.ps1" </PostBuildEvent> </PropertyGroup> ``` Is there a way to set the teambuild value based on the $(BuildingInsideVisualStudio) value inside the post build event? Something like If ($(BuildingInsideVisualStudio) == 'true') set TEAMBUILD = $True or even something like `set TEAMBUILD = $$(BuildingInsideVisualStudio)` ?

Original source