8

I'm having issues setting up different envirnoments with MSBuild and MSDeploy.

I've setup 2 configurations on TeamCity

  1. TestConfiguration (This builds the app in Test Config and runs unit tests)
  2. StagingConfiguration (Is meant to package and deploy to our staging box for UA testing)

My TestConfiguration works fine but the StagingConfiguration doesn't deploy the package.

<MSBuild Projects="MyProject\MyProject.csproj"
         Properties="Configuration=Staging;
         DeployOnBuild=true;
         DeployTarget=Package;"/>

I've tried adding both

_PackageTempDir=\\server\c$\WebDirectory;
PackageLocation=\\server\c$\WebDirectory;

But neither seem to do anything, am i missing the point? I've not really been able to find any documentation, just the odd blog post here and there. Do I need to install something on my TeamCity server for MSDeploy to work?

My ideal scenario is:

  1. Check in to tfs
  2. Run StagingConfiguartion in TeamCity manually
  3. Code is built and deployed to \server\c$\WebDirectory
abatishchev
  • 98,240
  • 88
  • 296
  • 433
Gilbert Liddell
  • 1,203
  • 4
  • 14
  • 21
  • What error messages do you get? – 8DH May 18 '11 at 10:03
  • Have you checked that the user account running the build agent has write access to the mentioned UNC path? – 8DH May 18 '11 at 10:04
  • You should consider building the msdeploy package during your CI build and having your 'deploy build' use msdeploy to delpoy the existing (build artifact) build package. In your approach you are rebuilding from sources on each deploy. – John Dhom Dec 27 '11 at 16:25
  • Check out [Troy Hunt's 5-part post](http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity.html), it's a very nice approach as it walks you through from Building to Deployment using TeamCity, and creating artifacts (the code that was built). His post uses Subversion though, but you can easily substitute it with TFS. – Bryan Hong Jan 27 '12 at 05:52

2 Answers2

4

You need to configure TeamCity "System Properties" that will be passed to MsBuild and control the MsDeploy pipeline.

It's a little tricky to get setup correctly but the ones you need to set are:

  • system.CreatePackageOnPublish=true
  • system.DeployOnBuild=true
  • system.DeployTarget=MSDeployPublish
  • system.MSDeployPublishMethod=WMSvc
  • system.DeployIISAppPath=[Default Web Site]
  • system.MSDeployServiceUrl=[yourServerDomainName]
  • system.Username=[username]
  • system.Password=[password]

I wrote a blog article with more detail here: Web Deploy (MS Deploy) from TeamCity - http://www.geekytidbits.com/web-deploy-ms-deploy-from-teamcity/

Here's what my config looks like: Screenshot of Example System Properties within Teamcity

Chris McKee
  • 4,298
  • 10
  • 48
  • 83
Brady Holt
  • 2,844
  • 1
  • 28
  • 34
3

When Visual Studio is not installed on the build server (which it should definitely not be) you need a few files from your dev machine to make things running:

From the C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0 folder on your dev machine copy the Web and Web Applications folders to the equivalent directory on your build server.

(from MSBuild target package not found)

Community
  • 1
  • 1
lasseschou
  • 1,550
  • 15
  • 24