Continuous Learning and Sharing of Team Foundation Server and Application Lifecycle Management RSS 2.0
# Saturday, September 26, 2009

In Part 1: The Deployment Process Should Enforce Good Configuration Management Practices, I gave some background on my experiences and how the configuration management process has evolved and some rules and benefits to the automated deployment MSIs.

In Part 2: How to create an automated deployment MSI, I walked through the steps to create an automated deployment MSI in Visual Studio satisfying the rules from Part 1.

In Part 3, I am going to walk through the steps to install Team Deploy.  Then walk through creating a team build, configure Team Deploy, and deploy a MSI with it. 

There is also a great Screencast by Ian Ceicys walking through the entire process of installing TFS, WIX, Team Deploy and deploying a MSI.  I highly recommend watching this.

Installing PS Tools

  • Team Deploy uses the free PSExec and PSKill utilities by Sysinternals (owned by Microsoft).  PSExec allows you to remotely run any command and PSKill can kill any process on a local or remote machine.
  • Download PSTools at http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx and install to a local folder.  I also recommend renaming psexec and pskill to something like psexec2.exe.  Some anti-virus software sees these files as a risk.

 

Installing Team Deploy

  • Browse to the Team Deploy website on CodePlex at http://TeamDeploy.CodePlex.com
  • Click on the Downloads and download the TeamDeploy.MSI.
  • Run the MSI to install Team Deploy to c:\Program Files\MSBuild\TeamDeploy
  • The windows service account that runs Team Build on the build server will need to be a local administrator on all target machines.

 

Creating a Team Deploy TFS Build

  • In Team Explorer, create a new build in your Team Project by right clicking on Builds and choosing “New Build Definition”

New Build Definition

 

  • Give it a name such as “Build and Deploy”
  • Create a workspace (Cloak other folders in your project that don’t need to be part of the build. This helps the speed up your build because otherwise the server will try to get all source files in the project)
  • Leave Project File name as is but click on the “Create” button to create a new TFSBuild.proj file.
  • Next choose the solution you want to build, then the configuration type. I recommend leaving the default.
  • Choose any options that you want to enable for running tests and/or code analysis. I would recommend leaving these unchecked for now and once you verify everything is working then go back and enable the options you want.
  • In TFS 2008, you can choose retention policies. This will help prevent builds from filling up your server disk space quickly. I usually choose Keep 7 latest.
  • the next options are for the Build Defaults. Choose the appropriate build agent. If unsure, just leave the default. Then choose the share where you want to copy the staging files.
  • The last option is “Trigger”. The "build and deploy" build should be separate from the continuous integration build. I recommend leaving the default “Check-ins do not trigger a new build”.

 

Build Trigger

 

  • Finally click “OK” to create the build type.

Creating the build definition will create the TFSBuild.proj that contains the basic options that were selected in the wizard. The following steps will customize the TFSBuild.proj file created. This file is a Xml file based on MSBuild.
  • To modify the TFSBuild.proj file, located the file under Source Control -> $/YourTeamProject/TeamBuildTypes/Build and Deploy (You can also navigate directly to this file by right clicking on the build definition and choosing "View Configuration Folder".)
  • Check out and open the TFSBuild.proj file to configure it to use Team Deploy
  • Find the comment <!—Do not edit this -> and add the following line underneath the one that is already there. It should look something like the screenshot below

<Import Project="$(MSBuildExtensionsPath)\TeamDeploy\TeamDeploy.Tasks.targets" />

AddTeamDeployProject.jpg

 

Scroll to the bottom of the TFSBuild.proj file to the <PropertyGroup>. Overwrite the Property group with the following (Adjust the paths for your specific environment):

<PropertyGroup>
    <KillAppPathFilename>c:\Program Files\PSTools\pskill2.exe</KillAppPathFilename>
    <RemoteExecutePathFilename>c:\Program Files\PStools\psexec2.exe</RemoteExecutePathFilename>
  </PropertyGroup>

  <!-- Deploy MSI  -->
  <Target Name="AfterEndToEndIteration">
    <CallTarget Condition="'$(IsDesktopBuild)'!='true'" Targets="DeployMSITargetVirtuals" />
  </Target>

  <Target Name="DeployMSITargetVirtuals">
    <Deploy DeployScript="$(SolutionRoot)\..\..\Push Scripts\SampleDeploy.xml"
            KillAppPathFilename="$(KillAppPathFilename)"
            RemoteExecutePathFilename="$(RemoteExecutePathFilename)"
            TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
            BuildUri="$(BuildUri)" />
  </Target>

The copied Xml in the TFSBuild.proj should look something like this

FinishedTFSBuild.jpg

  • Save and check-in the TFSBuild.proj file


The Deploy task uses a Xml Deploy Script that contains the information of what Msi(s) to deploy, additional tasks such as starting and stopping the service, and specifies the target machines. The following steps walks you through editing this file.

DeployScript.jpg

 

There are a few things to note here.

  • Team Deploy can
    • Kill 0 to many processes
    • Deploy/Uninstall 0 to many MSIs
    • Deploy MSIs to 0 to many Target Machines
  • Modify the xml appropriately for your environment. The GUID for the uninstalls are the MSI product codes. If the MSI is done correctly it will uninstall previous versions using the upgrade code, however they are usually unable to remove the same version of the MSI, this is why we have the separate step of uninstall.
  • The ExtraArgs element contains the SETUPENV variable that is used by the MSI’s custom action to copy the correct environment’s config file to the project’s. The custom action is a simple VBScript that copies the config file (not included with Team Deploy). See Part 2 for more details on creating the config files folder structure.

 

Once the TFSBuild.proj is checked in and the Deploy script is saved (or also checked in), then you can right click on the build and do a queue new build.   The MSI will be deployed to your target machine(s).

See the Troubleshooting / FAQ section of Team Deploy or contact me if you have any questions or problems.

Saturday, September 26, 2009 1:16:00 PM (Central Daylight Time, UTC-05:00)  #    Comments [0] -
Team Build | Team Deploy | Team Foundation Server

Visual Studio ALM MVP
Microsoft Visual Studio ALM MVP
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Mike Douglas
Sign In
Statistics
Total Posts: 76
This Year: 0
This Month: 0
This Week: 0
Comments: 52
All Content © 2012, Mike Douglas
DasBlog theme 'Business' created by Christoph De Baene (delarou)