How can I deploy an ASP.NET web application using Team Build?

I managed to install Team Foundation Server 2008, and I created a separate build server (which works because my builds do not currently work).

I created a simple Hello World web application (all this is the standard Default.aspx page) and connected to it in the TFS source control system.

Before TFS, I just pre-compiled my web application and xcopy results into a pre-created IIS virtual directory.

After cleaning Google for a while, I have yet to find a step-by-step guide on the correct deployment of the application from the TFS source through TeamBuild to a dedicated test web server. I know that MS Build falls into this equation, so any guidance would be helpful.

I've seen snippets of deployments that mention folders like _PublishedWebSites, but nothing has been found step by step.

+4
source share
3 answers

I had success using the exec task in target in AfterDropBuild in the TFSBuild.proj file.

<Target Name="AfterDropBuild> <Exec Command="xcopy /Y /E &quot;$(DropLocation)\\$(BuildNumber)\%(ConfigurationToBuild.FlavorToBuild)\_PublishedWebsites\MyWebsite1\*.*&quot; &quot;\\server\MyWebsite1\&quot;" /> <Exec Command="xcopy /Y /E &quot;$(DropLocation)\\$(BuildNumber)\%(ConfigurationToBuild.FlavorToBuild)\_PublishedWebsites\MyWebsite2\*.*&quot; &quot;\\server\MyWebsite2\&quot;" /> </Target> 

Note that permissions must be correctly configured for the TFS user to access the folder on the server to which you are copying.

+4
source

First, you should use WebDeployment projects, as this will do a lot more compiling and validating your code and markup. See here for more details.

I have 4 installation environments DV [Development], PY [Prototype], PP [Pre-Production], PD [Production] all the corresponding branches in TFS. Each of them also has an entry in the sln configuration manager, where you can configure which projects are needed for the assembly and the assembly flags.

After properly configured, you can begin to configure deployment scripts. I prefer to use MSbuild for deployment, as this will give you a much more subtle approach to deployment. MSbuild is a little strange to start with, that as soon as you receive it, it is powerful enough.

My deployment script, which is added to the TeamBuild configuration, is shown below. Basically, as you can see, I do a bit of cleanup after the build before copying to the servers. I also use 2 MSbuild frameworks (imported at the top).

 <Import Project="$(MSBuildExtensionsPath)\Microsoft\SDC Tasks - Release 2.1.3155.0\Microsoft.Sdc.Common.tasks"/> <Import Project="$(MSBuildExtensionsPath)\FreeToDev\MSBuild Tasks Suite 3.5\FreeToDev.MSBuild.tasks"/> <PropertyGroup> <InetpubFolder>\\PathToInetPub</InetpubFolder> <AppFolder>AppFolder</AppFolder> <AppFolderPath>$(InetpubFolder)$(AppFolder)</AppFolderPath> <WebDeployName>WebDeployProjectName</WebDeployName> <Debug>0</Debug> <AppConfiguration>DV</AppConfiguration> </PropertyGroup> <Target Name="AfterDropBuild"> <Message Text="Begin Release to $(AppConfiguration) Webserver" /> <Message Text="DropLocation = $(DropLocation)" /> <CallTarget Targets="PostBuildCleanUp" /> <CallTarget Targets="DeployApp" /> </Target> <Target Name="DeployApp"> <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)"> <Output TaskParameter="DropLocation" PropertyName="DropLocation"></Output> </GetBuildProperties> <PropertyGroup> <CodeDropLocation>$(DropLocation)\$(AppConfiguration) Release</CodeDropLocation> </PropertyGroup> <ItemGroup> <AppFilesToDelete Include="$(AppFolderPath)\**\*.*" Exclude="$(AppFolderPath)\Library\*.*;$(AppFolderPath)\App_Offline.htm;$(AppFolderPath)\jobs\**\*.*" /> </ItemGroup> <ItemGroup> <FilesToDeploy Include="$(CodeDropLocation)\$(AppFolder)\**\*.*" Exclude="" /> </ItemGroup> <Copy SourceFiles="$(CodeDropLocation)\$(AppFolder)\App_Offline[RemoveToActivate].htm" DestinationFiles="$(AppFolderPath)\App_Offline.htm" OverwriteReadOnlyFiles="true"/> <Message Text="Deleting files in $(AppFolderPath)" /> <Microsoft.Sdc.Tasks.File.DeleteFiles Files="@(AppFilesToDelete)" Force="true" Condition="$(Debug)==0" /> <Message Text="Copy $(CodeDropLocation)\$(AppFolder) to $(AppFolderPath)" /> <Copy Condition="$(Debug)==0" SourceFiles="@(FilesToDeploy)" DestinationFiles="@(FilesToDeploy->'$(AppFolderPath)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true"/> <Message Text="Deploy to $(AppConfiguration) Completed" /> <Microsoft.Sdc.Tasks.File.DeleteFiles Files="$(AppFolderPath)\App_Offline.htm" Force="true" /> <OnError ExecuteTargets="ErrorHandler" /> </Target> <Target Name="ErrorHandler"> <Message Text="Error encountered!!" /> </Target> <Target Name="PostBuildCleanUp"> <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)"> <Output TaskParameter="DropLocation" PropertyName="DropLocation"></Output> </GetBuildProperties> <PropertyGroup> <CodeDropLocation>$(DropLocation)\$(AppConfiguration) Release</CodeDropLocation> </PropertyGroup> <ItemGroup> <PostBuildCleanUpFilesToDelete Include="$(CodeDropLocation)\*.*;$(CodeDropLocation)\bin\*.xml;$(CodeDropLocation)\bin\*.pdb"/> </ItemGroup> <RemoveDir Directories="$(CodeDropLocation)\_PublishedWebsites\Web" /> <Microsoft.Sdc.Tasks.File.DeleteFiles Files="@(PostBuildCleanUpFilesToDelete)" Force="true"> <Output TaskParameter="DeletedFiles" ItemName="FilesThatWereDeleted" /> </Microsoft.Sdc.Tasks.File.DeleteFiles> <Message Text="The files that were removed were @(FilesThatWereDeleted)" /> <FTDFolder TaskAction="Move" Path="$(CodeDropLocation)\_PublishedWebsites\$(WebDeployName)" TargetPath="$(CodeDropLocation)\$(AppFolder)"/> <RemoveDir Directories="$(CodeDropLocation)\_PublishedWebsites" /> <RemoveDir Directories="$(CodeDropLocation)\$(AppFolder)\WebDeploy" /> <OnError ExecuteTargets="ErrorHandler" /> </Target> 

Obviously, you will need to change the system settings. It also cleans the target folder before it starts to copy the new assembly. This is to ensure that they are clean, but obviously you will need to add everything you need to the ExcludedFiles list.

I also have a folder for each environment in the main application project. This contains replacements for web.config (another feature of WebDeployment projects) and any other special environement files.

It will be a long process to get it working correctly, but hopefully it helps you get started! (Obviously, if you choose this apporach!)

+4
source

This can be done using build scripts directly, Vertigo Software guys are usually the best source of information for many TFS questions like this ... unfortunately, their blog posts usually do not occupy a high place on google. This is one of Jeff Atwood, one of the creators of this site:

Copying Web Files After Team Build

+2
source

All Articles