Question

I have 3 MSBUild scripts for deployment, 1 for deploying UI 1 for deploying a couple of web services. 1 for deploying backend services.

Now I would like to create a one click deployment MSBuild script, which would call all the above 3 scripts, which can be executed from a TeamCity server.

So how can I call these three MSBuild scripts from a different MSBuild Script.

Was it helpful?

Solution

There is a MSBuild MSBuild task.

OTHER TIPS

I have not used TeamCity Server, but one possible alternate solution is to combine the three build scripts into one script. And put tasks of the three separate scripts into separate targets in the master build file. So, instead of the three separate build scripts, you have one build script with three targets, namely deployUI, deployServices, deployBackend. Untested sample below:

    <?xml version="1.0" encoding="utf-8" ?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="DefaultTarget" ToolsVersion="3.5">

    <Target Name="DefaultTarget">
            <CallTarget Targets="deployUI" ContinueOnError="false"></CallTarget>
            <CallTarget Targets="deployServices" ContinueOnError="false"></CallTarget>
            <CallTarget Targets="deployBackend" ContinueOnError="false"></CallTarget> 
    </Target>

    <Target Name="deployUI">
            <!-- Put UI deployment tasks here -->
    </Target>

    <Target Name="deployServices">
            <!-- Put Services deployment tasks here -->
    </Target>

    <Target Name="deployBackend">
            <!-- Put Backend deployment tasks here -->
    </Target>
</Project>

In MSBuild 4.0 an option might be to conditionally import the 3 project files into your one click deployment MSBuild script:

<Import Project="ProjectPath1" Condition="'$(DeployUI)'!=''" />
<Import Project="ProjectPath2" Condition="'$(DeployWebServices)'!=''" />
<Import Project="ProjectPath3" Condition="'$(DeployBackendServices)'!=''" />

<Target Name="DeployTheWorld">
    <Message Text="Deploying..." />
</Target>

Then use the AfterTargets feature on the targets you wish to run in your separate project files that you have imported:

  <Target Name="DeployUI" AfterTargets="DeployTheWorld">
    <Message Text="Hello from DefaultAfterTarget"/>
  </Target>

This will give you flexibly in customising the deployment from within TeamCity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top