How To Deploy an ASP.NET web application using Team Foundation Server
Here is a quick tip on how to modify a TFS build script to publish an ASP.NET site to an existing IIS server (i.e. development environment).
Sample Code
Assuming you have created your basic TFSBuild.proj file, add this to the bottom of the file (right before the </project> tag):
<!– This task will be executed after the build is copied to the drop location (i.e. build storage) and
will take care of automating the deployment of the project to an IIS folder
by ‘Wagner Danda da Silva’
–>
<Target Name=”AfterDropBuild” Condition=” ‘$(BuildBreak)’!=’true’ “>
<!– Let’s prepare the copy by setting the drop location (IIS website folder) ** –>
<CreateProperty Value=”\\dswebdev\QA\“> <!– replace this with your IIS folder –>
<Output TaskParameter=”Value” PropertyName=”MyDropLocation”/>
</CreateProperty>
<!– The path below is where the sources can be found after building ASP.NET projects, you probably won’t need to edit this. –>
<CreateItem Include=”$(DropLocation)\$(BuildNumber)\%(ConfigurationToBuild.FlavorToBuild)\_PublishedWebsites\Web\ \*”>
<Output TaskParameter=”Include” ItemName=”MyDropFiles”/>
</CreateItem>
<!– Let’s remove any pre-deployed files. This will delete any existing files inside all folder and subfolders of the drop location. I opted not to use the default TFS delete task because that was removing security permission on my folders and messing up with my build. The command below won’t do that, will simply delete old files (but it won’t remove the folders, so if you deleted a folder on your source code you’ll have to manually remove it from the drop location – if you actually care for that
–>
<Exec Command=’del /f /s /q $(MyDropLocation)\*’/>
<!– Copy the files from the build drop location to the IIS website folder –>
<Exec Command=’xcopy /Y /R /E “$(DropLocation)\$(BuildNumber)\%(ConfigurationToBuild.FlavorToBuild)\_PublishedWebsites\Web\.” “$(MyDropLocation)\."’ />
</Target>
More details can be found here:http://tfsdeploy2iis.codeplex.com/