Thursday, April 5, 2012

How to check if an MsBuild property exists?

I’m converting a Nant build script to MsBuild.
In Nant I have the following statement to check if a specific build property exists:
<if test="${property::exists('application.environment')}">

To do the same thing in MsBuild you have to use the condition attribute:

<PropertyGroup> 
       <ApplicationEnvironment Condition="'$(ApplicationEnvironment)' == ''">UAT</ApplicationEnvironment> 
</PropertyGroup> 

No comments: