04 December 2014 MSBuild, WebDeploy, TFS Robert Muehsig

With this blogpost I will show you how you can trigger WebDeploy to deploy your WebApp - without complicated scripts or scary build workflow systems.

WebDeploy, MSBuild - what?

This is not a introduction blogpost about MSBuild or WebDeploy, but I will try to give you a very short description.

MSBuild: Every time you open a .csproj file you work with MSBuild. MSBuild is XML-based and the primary build “language” for .NET projects.

WebDeploy: WebDeploy is a modern alternative to FTP - the WebDeploy Packages contains the WebApp (in most cases a ASP.NET WebApp) and configuration details for IIS, connections to database etc.

The hardest challenge might be to get WebDeploy running. In theory it is not hard, but there are some tricky problems in certain situations. I already have a couple of posts about WebDeploy-Setup on this Blog.

MSBuild Parameter to trigger WebDeploy

The typical MSBuild call is:

msbuild app.csproj /p:configuration=Release

To trigger MSBuild there are a couple of MSBuild arguments:

/p:DeployOnBuild=True
/p:DeployTarget=MsDeployPublish
/p:MSDeployServiceURL=https://<server name>:8172/msdeploy.axd
/p:DeployIISAppPath=”TestSiteForDeploy”
/p:CreatePackageOnPublish=True
/p:MsDeployPublishMethod=WMSVC
/p:AllowUntrustedCertificate=True
/p:UserName=*****
/p:Password=*****

Most of these properties are listed here.

So you just need to apply all parameters to your MSBuild call and it should build the package (you also may need the OutputPath and Configuration property) and publish it via WebDeploy.

TFS and other Build Systems

If you just have simple requirements you could just add the deployment arguments to your CI-Build and everything should work. In the TFS World you can specify additional MSBuild args. You can do similar things in TeamCity and other Build Systems.

x

As I said in the beginning - it is simple and I found this solution on this Blog, but just to remind me better next time I reblogged it here with my own words.

Hope this helps!


Written by Robert Muehsig

Software Developer - from Dresden, Germany, now living & working in Switzerland. Microsoft MVP & Web Geek.
Other Projects: KnowYourStack.com | ExpensiveMeeting | EinKofferVollerReisen.de

If you like the content and want to support me you could buy me a beer or a coffee via Litecoin or Bitcoin - thanks for reading!