MSBuild passing parameters to CallTarget

Viewed 43135

I'm trying to make a reusable target in my MSBuild file so I can call it multiple times with different parameters.

I've got a skeleton like this:

<Target Name="Deploy">
    <!-- Deploy to a different location depending on parameters -->
</Target>

<Target Name="DoDeployments">
    <CallTarget Targets="Deploy">
        <!-- Somehow indicate I want to deploy to dev -->
    </CallTarget>

    <CallTarget Targets="Deploy">
        <!-- Somehow indicate I want to deploy to testing -->
    </CallTarget>
</Target>

But I can't work out how to allow parameters to be passed into the CallTarget, and then in turn the Target itself.

4 Answers
    <CreateProperty
        Value="file1">
        <Output
            TaskParameter="Value"
            PropertyName="filename" />
    </CreateProperty>
    <CallTarget Targets="Deploy"/>
    <Message Text="$(filename)"/>
    <CreateProperty
        Value="file2">
        <Output
            TaskParameter="Value"
            PropertyName="filename" />
    </CreateProperty>
    <Message Text="$(filename)"/>   
    <CallTarget Targets="Deploy"/>
Related