7

I've been trying to figure this out and so far haven't found a simple solution. Is it really that hard to deploy a database project (and a web site) using TFS 2010 as part of the build process?

I've found one example that involved lots of complicated checks and editing the workflow (which is a giant workflow btw).

I've even purchased the book "professional application lifecycle management with VS 2010", but apparently professionals don't deploy their applications since it isn't even mentioned in the book.

I know I'm retarded when it comes to TFS, but it seems like there should be any easy way to do this. Is there?

Bryant
  • 8,660
  • 1
  • 33
  • 53
  • If you run into problems with what I posted below please comment and I'll update...since it's a very new thing without a lot to google on yet, I had the same experience as you figuring it out as I went along. If I forgot anything I'd like to update the answer to include it so we can save someone the same experience I went through...price you pay for using the newest things I suppose. – Nick Craver May 20 '10 at 23:26
  • Looks like a great answer. I did figure out deploying the database so I'm going to try to implement your answer here in a bit, if it works I'll be sure to mark it as the answer. Thanks! – Bryant May 21 '10 at 01:27
  • Related - http://stackoverflow.com/questions/2636153/how-can-i-get-tfs2010-to-run-msdeploy-for-me-through-msbuild – Maslow Jul 01 '11 at 12:55

1 Answers1

7

I can't speak for the database portion, but I just went through this on the web portion, the magic part is not very well documented component, namely the MSBuild Parameters.

In your build definition:

  1. Process on the Left
  2. Required > Items to Build > Configurations to Build
    • Edit, add a new one, for this example
      • Configuration: Dev (I cover how to create a configuration below)
      • Platform: Any CPU
  3. Advanced > MSBuild Process
    • Use the following arguments (at least for me, your publish method may vary).

MsBuild Params:

/p:MSDeployServiceURL="http://myserver"  
/p:MSDeployPublishMethod=RemoteAgent 
/p:DeployOnBuild=True 
/p:DeployTarget=MsDeployPublish 
/p:CreatePackageOnPublish=True 
/p:username=aduser
/p:password=adpassword

Requirements:

  1. You need to install the MS Deploy Remote Agent Service on the destination web server, MSDeploy needs to be on the Build/Deployer server as well, but this should be the case by default.
  2. The account you use in the params above needs admin access, at least to IIS...I'm not sure what the minimum permission requirements are.

You configure which WebSite/Virtual Directory the site goes to in the Web project you're deploying. Personally I have a build configuration for each environment, this makes the builds very easy to handle and organize. For example we have Release, Debug and Dev (there are more but for this example that's it). Only the Web project has a Dev configuration.

To do this, right click the solution, Configuration Manager..., On the web project click the configuration drop down, click New.... Give it a name, "Dev" for this example, copy settings from debug or release, whatever matches closest to what your deployment server environment should be. Make sure "Create new solution configurations" is checked, it is by default. After creating this, change the configuration dropdown on the solution to the new Dev one, and Any CPU...make sure your projects are all correct, I had some flipping to x86 and x64 randomly, not sure of the exact cause of that).

In your web project, right click, properties. On the left, click Package/Publish Web (you'll also want to mess with the other Package/Publish SQL tab, but I can't speak to that). In the options on the right click Create deployment package as a zip file. The default location is fine, the next textbox I didn't find documented anywhere. The format is this: WebSite/Virtual Directory, so if you have a site called "BuildSite" in IIS with no virtual directory (app == site root), you would have BuildSite only in this box. If it was in a virtual directory, you might have Default Web Site/BuildVirtualDirectory.

After you set all that, make sure to check-in the solution and web project so the build server has the configuration changes you made, then kick off a build :)

If you have more questions, I recommend you watch this video by Vishal Joshi, specifically around 22 and 59 minutes in, he covers the database portion as well...but I have no actual experience trying it since we're on top of a non MSSQL database.

Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
  • Is there a way to use windows auth rather than a hardcoded username/password? – Maslow Jul 01 '11 at 12:50
  • @Maslow - not that I'm aware of - it could be allowed somewhere but I've never seen this documented (though the documentation is slim at best to begin with...so it's possible) – Nick Craver Jul 01 '11 at 13:25