visual studio - Check if PropertyGroup item is set to a value in .csproj -
i using .targets
files include common functionality in .csproj files.
in target file, want check if property set before, , if yes, not set again.
i need because using specific target file in many solutions, , want include custum property if wasn't set before.
the property talking
<propertygroup> <codeanalysisruleset>$(solutiondir)customizedallrules.ruleset</codeanalysisruleset> </propertygroup>
if ruleset specified before importing target file, don't want include again in .targets
file.
how check in .csproj if <codeanalysisruleset>...</codeanalysisruleset>
set before?
the pattern i've seen set conditionally based on comparing empty value:
<propertygroup> <codeanalysisruleset condition="'$(codeanalysisruleset)' == ''">$(solutiondir)customizedallrules.ruleset</codeanalysisruleset> </propertygroup>
[edit: responding comment code example]
here's longer example works me:
<project toolsversion="4.0" defaulttargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <propertygroup> <propertyvalue condition="$(propertyvalue) == ''">default value</propertyvalue> </propertygroup> <target name="build"> <message text="$(propertyvalue)" /> </target> </project>
gives console output:
project "d:\temp\test.proj" on node 1 (default targets). build: default value done building project "d:\temp\test.proj" (default targets).
Comments
Post a Comment