Copying a new build to all environments

I am doing this task again and again, so maybe this code will be helpful not only for me.

That is a standard routine. I am developing a BizTalk Server applications and use the BizTalk Deployment Framework (BTDF) for all my deployments. When an application is ready for testing and, at the end, for production, the build files have to be deployed. Usually the BizTalk installation has several environments. For example, the environments can be: Development, QA, Staging, Production. Sometime less, sometime more. The best practice is to keep all environments isolated of each other. So each environment keeps its deployment packages separately. That means, in my case, the build files should be copied to all environments.

A good practice is to save the old builds in case of rollback.

The folder structure for the builds looks like this:


The Current folder keeps the currently deployed build. The [YYYYMMDD_hh_mm_ss] folders keep the old builds.

What is interesting in this code?

The Copy performs two nested loops. One through the EnvironmentName and the second through the NewBuildToCopy files.

Also the code generated the folder name in [YYYYMMDD_hh_mm_ss] format.

Here is the code:

<!-- Copy a new deployment build to all environments and to a Personal share. 
  Before this rename a Current folder to the [CurrentDateTimeTime] to save an old build. 
<Target Name="AfterInstaller" AfterTargets="Installer">

  <!-- Rename Current shares to the [CurrentDateTime]: -->
    <EnvironmentName Include="QA;STG;PROD"/>
    <CurrentShare Include="$(Shares)%(EnvironmentName.Identity)$(SourceCodeShare)" />
    <CurrentShare Include="$(PersonalShare)" />

  <Exec Condition="Exists('%(CurrentShare.Identity)\Current')"
         Command='Rename "%(CurrentShare.Identity)\Current" "$(CurrentDateTime)"'/>

    <NewBuildToCopy Include="$(NewBuild)\**\*.*">

  <!-- Copy the last build to the Current shares: -->
  <Copy Condition="@(NewBuildToCopy) != ''"
        DestinationFiles="@(NewBuildToCopy->'%(Destination)\Current\%(RecursiveDir)%(Filename)%(Extension)')" />

This target could be a part of the Deployment.btdfproj file (which is a file from the BTDF Deployment project). Also you can add it to the BizTalkDeploymentFramework.targets file.
Print | posted on Friday, September 20, 2013 7:55 PM


# re: Copying a new build to all environments

left by Stuart Brierley at 9/23/2013 1:42 AM Gravatar
This looks like it could be an interesting solution to a similar problem that we need to solve.

Thanks for sharing.
Post A Comment