How-To Integrate IIS 7 Web Deploy with MSBuild (TeamCity) ?
Troy Hunt has an excellent 5-part blog series that goes over this topic in detail.
He has effectively compiled all of the other resources out there and turned them into a tutorial.
It's the clearest (and believe it or not, the most concise) way to do what you want.
I finally managed to get it to work after several days of struggle. It finally boils down to a MSBuild script, installing and configuring web deploy on the staging/test server and setting it up in Team City.
It's a lot of steps and all can go wrong. I will investigate further and blog about it but this is my first attempt that works.
I'm using this setup:
Here is the MSBuild script:
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration>Release</Configuration> <Platform>AnyCPU</Platform> </PropertyGroup> <Import Project="Webapplication.csproj" /> <Target Name='Deploy' DependsOnTargets='Build;Package' > <Exec Command='"C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -source:contentpath="$(teamcity_build_checkoutDir)\Main\source\Webapplication\obj\Release\Package\PackageTmp\" -dest:contentpath="c:\inetpub\Webapplication\www",includeAcls=false,computername="https://(stagingserver-name):8172/msdeploy.axd?Site=Webapplication",authType=Basic,userName=(staginserver-name)\webdeploy,password=******** -allowUntrusted -verb:sync' /> </Target> </Project>
Key points:
Preparations:
Team City:
I set up a new build configuration using the MSBuild script above and set the target to Deploy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With