I’m trying to set a default value for an MSBuild property. Say I start with this:
<Choose>
<When Condition="..something..">
<PropertyGroup>
...
<MySetting>true</MySetting>
<PropertyGroup>
</When>
...
</Choose>
If the condition is not true, then MySetting will be ”. So shouldn’t this set it to false?
<PropertyGroup>
<MySetting Condition="'$(MySetting)'==''">false</MySetting>
</PropertyGroup>
Later on, I’d like to use MySetting in a conditional without having to test for ==’true’, like this:
<PropertyGroup Condition="$(MySetting)">
...
</PropertyGroup>
Yet when I load this project into Visual Studio it complains that the specified condition “$(MySetting)” evaluates to “” instead of a boolean.
So it appears that either my condition that checks for ” to assign the property to false is incorrect. What am I doing wrong?
In MSBuild, you’re dealing with strings so you get the
''instead offalse…if you want to default it to'false'and override via the command line, just declare a property group above your existing condition block in the script:Your condition block below can set this to true, or you could also set it via the command line, like this: