What is the preferred way of "passing" preprocessor constants to predefined blocks in CC.NET?
Assuming I have the following declarations:
<cb:define name="ProjectHeaderBlock">
    <name>$(ProjectName)</name>
    <workingDirectory>C:\MyProjects\$(ProjectName)</workingDirectory>
</cb:define>
<cb:define name="ProjectBlock">
    <project>
        <cb:ProjectHeaderBlock />
        <triggers />
        <tasks />
        <publishers />
    </project>
</cb:define>
I can pass the ProjectName constant in two ways:
Using cb:scope
<cb:scope ProjectName="FooProject" >
    <cb:ProjectBlock />
</cb:scope>
Passing directly in declaration
<cb:ProjectBlock ProjectName="FooProject" />
They both worked properly and inner ProjectHeaderBlock was initialized with proper ProjectName value.
Are there any differences between these two options? Which one is better/more efficient?
You're right: They work both. The only functional difference that I'm aware of is that preprocessor contants defined in scope elements are overwritable i.e., they may be redefined later.
I use scope defined preprocessor constants for setting default values which I overwrite if necessary.
Personally I prefer the second version as it avoids nesting in your xml.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With