;

TeamCity with VS2012 and .Net4.5 using WebDeploy3.0

Posted : Wednesday, 12 June 2013 07:23:00

I love the whole CI/CD thing and any clients that I have set it up for have benefitted enormously. For my current client I was tasked with reviving and improving the continuous integration that their previous architect had created. I hadn’t used TeamCity before so this was a great chance to jump in. For whatever reason the CI hadn’t been running for a while – the main problem was the build up of incorrect  reference paths – these seem to get added either by ReSharper (which I have paid for and love btw) or as a by product of using a solution build directory. Once we got the build compiling, we began running tests again and the CI server is back keep quality high. My personal drive for doing this is the countless hours I have wasted copying and pasting assemblies, running batch files and editing configuration files in numerous error-prone deployment scenarios.

The next step in the journey was to get a nice automated deployment solution – the first target was a commit-triggered web deploy to IIS. I used this post from Tory Hunt - seriously this is awesome, and of course one from Scott Hanselman. Troy’s was written a few years ago so I think there have been a few changes to visual studio and web deploy. I worked through Troy’s post and along the way a few errors came up, generally about command line parameters being passed to MSBuild. I’ve added a comment for the ones I had to add in addition to those described in Troy and Hanselman’s posts. Hope they benefit someone….

1) The first thing I had to do was install Windows 7.1 SDK developer tools. I *think* this is because there are a couple of WCF services in the solution and the compiler needs to generate the serialization assemblies. SGen.exe is on developer machines because from what i read Visual Studio installs it, and installing Visual Studio on a build server is just wrong, right?

2) In order to get the builds compiling and deploying I had to add/alter some command line parameters, listed below….

 

        //Debug,Staging,Release etc.

        //%env.Configuration% is configured in TeamCity

        /P:Configuration=%env.Configuration%

 

        //x86,x64,AnyCPU etc.

        //%env.Platform% is configured in TeamCity

        /P:Configuration=%env.Platform%

 

        //solution dir for compilation - required if you use a solution build directory

        //%system.teamcity.build.workingDir% is configured in TeamCity

        /P:SolutionDir="%system.teamcity.build.workingDir%/Source"

 

        //instucts MSBuild to create a deployment package

        /P:CreatePackageOnPublish=True

 

        //causes the package created to be deployed to /P:MsDeployServiceUrl

        /P:DeployOnBuild=True

 

        //msbuild target for web deploy

        /P:DeployTarget=MSDeployPublish

 

        //msdeploy publish method - recommendation is to use Web Management Service

        /P:MSDeployPublishMethod=WMSvc

 

        //name of IIS site into which this package will be deployed

        //%env.TargetServer% is configured in TeamCity

        //NB user account specified must have permission to do this via IIS Manager

        //or by a local admin on web server

        /P:MsDeployServiceUrl=https://%env.TargetServer%/MsDeploy.axd?Site="MyWebSite"

 

        //path to application in IIS

        //this will be same as /P:MsDeployServiceUrl for root sites

        //or full path if deploying nested application

        /P:DeployIisAppPath="MyWebSite/NestedApplication"

 

        //required if using self signed certificate on web server

        /P:AllowUntrustedCertificate=True

 

        //username of account that will be used to deploy application

        //NB must be configured via IIS or be a local admin

        //%deploy.username% is configured in TeamCity

        /P:UserName=%deploy.username%

 

        //password for deployment account

        //%deploy.password% is configured in TeamCity

        /P:Password=%deploy.password%

 

      &

  • (This will not appear on the site)