Click here to Skip to main content
13,152,289 members (40,318 online)
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 21 Sep 2013

Copying a New Build to All Environments

, 24 Sep 2013
Rate this:
Please Sign up or sign in to vote.
A Target for MSBuild, which I use with BizTalk Deployment Framework (BTDF) for the BizTalk Server application deployment.


A target for MSBuild, which I use with BizTalk Deployment Framework (BTDF) for the BizTalk Server application deployment. But it is pretty generic and can be used whenever you need to copy a folder structure (files and sub-folders) into several places simultaneously. 

Using the Code

This MSBuild 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 of to any .target file.

Points of Interest

Here, I have to do a double loop in the Copy with two items, NewBuildToCopy files and EnvironmentName.

Also, it generates a folder name in the [YYYYMMDD_hh_mm_ss] format.


<!-- 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) != ''"


        '%(Destination)\Current\%(RecursiveDir)%(Filename)%(Extension)')" />


That is a standard routine. I am developing a BizTalk Server application and use the BizTalk Deployment Framework (BTDF) for all my deployments. When an application is ready for testing, 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 (here they are QA, STG, PROD). Sometimes less, sometimes 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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Leo Gan
Web Developer
Canada Canada
This member doesn't quite have enough reputation to be able to display their biography and homepage.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170924.2 | Last Updated 24 Sep 2013
Article Copyright 2013 by Leo Gan
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid