JG Vimalan's Blog

It is all about coding!

Automated deployment build

When you create a new build definition in tfs, you will get a .proj file created. You need to make few changes to deploy your application to the destination server automatically. Here is a sample .proj file, which deploy and make changes in the web.config automatically,

<?xml version=”1.0″ encoding=”utf-8″?>
<!– DO NOT EDIT the project element – the ToolsVersion specified here does not prevent the solutions
     and projects in the SolutionToBuild item group from targeting other versions of the .NET framework.
     –>
<Project DefaultTargets=”DesktopBuild” xmlns=”http://schemas.microsoft.com/developer/msbuild/2003” ToolsVersion=”3.5″>
 
  <!– Do not edit this –>
  <Import Project=”$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets” />
  <Import Project=”$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets”/>
 
  <ProjectExtensions>
 
    <!– Team Foundation Build Version – DO NOT CHANGE –>
    <ProjectFileVersion>2</ProjectFileVersion>
 
    <!–  DESCRIPTION
     This property is included only for backwards compatibility. The description of a build definition
     is now stored in the database. For compatibility with V1 clients, keep this property in sync with
     the value in the database.
    –>
    <Description></Description>
 
    <!–  BUILD MACHINE
     This property is included only for backwards compatibility. The default machine used for a build
     definition is now stored in the database, as the MachineName property of the definition’s
     DefaultBuildAgent. For compatibility with V1 clients, keep this property in sync with the value
     in the database.
    –>
    <BuildMachine>ABC1234</BuildMachine>
 
  </ProjectExtensions>
 
  <PropertyGroup>
 
 
   <MyProjInstallDirectory>\\ABC1122\E$\Inetpub\wwwroot\MyProjName</MyProjInstallDirectory>
 
   …………..
   …………..

  </PropertyGroup>
 
  <ItemGroup>
 
    <MyProjectApplicationFiles Include=”D:\Builds\$(BuildDefinitionId)\Binaries\Release\_PublishedWebsites\MyProj.UI\**\*.*”/>
 
   …
   …

   <SolutionToBuild Include=”$(BuildProjectFolderPath)/../../../../Prod/MyProject/MyProj.sln”>
      <Targets></Targets>
      <Properties></Properties>
    </SolutionToBuild>
 
  </ItemGroup>
 
 ….
 ….
 
  </PropertyGroup>
 
  <ItemGroup>
    <!–  ADDITIONAL REFERENCE PATH
     The list of additional reference paths to use while resolving references. For example:
    
         <AdditionalReferencePath Include=”C:\MyFolder\” />
         <AdditionalReferencePath Include=”C:\MyFolder2\” />
    –>
  </ItemGroup>
 
  <Target Name=”AfterTest”>
 
    <Message Text=”Updating Web.config” />
 
   
    <XmlUpdate
       Namespace=””
       XmlFileName=”D:\builds\$(BuildDefinitionId)\Binaries\Release\_PublishedWebsites\MyProject\MyProj.WebUI\Web.Config”
       Xpath=”//configuration/appSettings/@file
       Value=”Web.Live.config” />
 
    <XmlUpdate
       Namespace=””
       XmlFileName=”D:\builds\$(BuildDefinitionId)\Binaries\Release\_PublishedWebsites\MyProject\MyProj.WebUI\Web.Config”
       Xpath=”//configuration/system.web/compilation/@debug
       Value=”false” />
 
    <Message Text=”Copying source files to live” />
 
    <Copy SourceFiles=”@(MyProjectApplicationFiles)” OverwriteReadOnlyFiles=”true” DestinationFolder =”$(MyProjInstallDirectory)\%(RecursiveDir)” />
 
 
  </Target>
 
</Project>

Advertisements

September 28, 2010 - Posted by | TFS

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: