Reputation: 2485
I have a target as part of my build that I wish to skip upon evaluation of some command line check:
<Target Name="RunSomeDependencyVerification" Condition="!Exists('$(SkipVerification)')">
....
I want to pass the skip verification in from the console such that:
msbuild mybuild.dev.proj /p:SkipVerification
My build script complains that the "SkipVerification" property is not defined. I've found the documentation for <PropertyGroup />
but it seems like that not only defines the property, but sets the value too, which isn't what I'm after.
What am I missing?
Upvotes: 2
Views: 2879
Reputation: 27842
Define your property with a default value in your original msbuild file.
<PropertyGroup>
<SkipVerification Condition="'$(SkipVerification)'==''">False</SkipVerification>
</PropertyGroup>
Your use of "Exists" check is off I think.. (aka, nicely saying: it is the wrong syntax-sugar for what you are trying to do.) I think you want to check the VALUE of your property. As seen below: (no "Exists" used :) )
<Target Name="RunSomeDependencyVerification" Condition="'$(SkipVerification)'=='True'">
Then this.
/p:Configuration=Debug;SkipVerification=True
Please note:
Configuration=Debug; is not a part of what you need, I just wanted to show how to specify more than 1 property in the command line. (that you use a ";" delimiter)
Upvotes: 3
Reputation: 35901
Msbuild says SkipVerification
is not defined because it isn't: Exists
is for files or directories, not for properties. Try this instead:
msbuild mybuild.dev.proj /p:SkipVerification=true
And then check on the value:
<Target Name="RunSomeDependencyVerification"
Condition="'$(SkipVerification)'!='true')">
Upvotes: 0