Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing constants to predefined blocks with CruiseControl.NET preprocessor

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:

  1. Using cb:scope

    <cb:scope ProjectName="FooProject" >
        <cb:ProjectBlock />
    </cb:scope>
    
  2. 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?

like image 592
Maciej Wozniak Avatar asked Oct 08 '22 19:10

Maciej Wozniak


1 Answers

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.

like image 122
The Chairman Avatar answered Oct 11 '22 09:10

The Chairman