3

I have been reading about building once and then configuring for each environment. For example, here are some ideas how to do this: Build once and deploy to multiple environments with msdeploy & Visual Studio 2012

My question is, how does this work together with your build server? Does anyone ever kick off one build that deploys to multiple environments? I would expect each environment would have its own build definition with its own rules/schedule. In that case, how feasible is it really to build once? I feel like I'm missing something...

Community
  • 1
  • 1
Nelson Rothermel
  • 9,436
  • 8
  • 62
  • 81

2 Answers2

3

I work with a build pipeline based on MSDeploy and the Web Publishing Pipeline, but it's not a scenario directly supported by the MSBuild scripts.

The basic premise I use is that a package is built during the first "stage" of the build and then deployed to various environments until it's in production. How your build server handles cross-build "artifacts" is something you'll need to look into.

The other problem is that deploying a package to a publish profile is not something that's currently supported. However, you always have the alternative of deploying the package from the command line (or even uploading it to an administrator who can import it via IIS).

These resources (which, disclaimer, include links to my own blog and code) should help:

Community
  • 1
  • 1
Richard Szalay
  • 83,269
  • 19
  • 178
  • 237
3

I do this all the time. Build once and reconfigure for each environment. I dont use MSdeploy. I do use xdt templated transforms, these are combined with environment properties at deploy time. The build creates a package, which can be configured.

This eliminates the need for visual studio at deploy time. I can kick off deploys to multiple environments. I can also support new/changed environment at deploy time. You can achieve this easily using msbuild, the ctt tool http://ctt.codeplex.com/documentation and a token transform process such as the detokenisation task in the msbuild extension pack. If you build this processyou can host in a CI tool (TFS but id got for Teamcity) as well as manually/cmdline/powershell.

James Woolfenden
  • 6,498
  • 33
  • 53
  • +1 for your example and CTT (I didn't know you could obtain it stand-alone). For the moment I'm looking for a more built-in way of doing all this, but if I keep hitting dead-ends this may be a good option. – Nelson Rothermel Mar 04 '13 at 17:54
  • Keep in mind that MSDeploy comes in a command line that's installed separately from VS. The VS additions are simply MSBuild scripts. – Richard Szalay Mar 05 '13 at 06:14
  • ctt also let you use the same method to configure any type of application that has config files not just web applications. – James Woolfenden Mar 05 '13 at 07:40
  • Actually MSDeploy can deploy folders to folders, not just web application, and it's [parameter system](http://technet.microsoft.com/en-us/library/dd569084%28v=ws.10%29.aspx) goes beyond just xml files. Plus it can deploy SQL scripts and set server ACLs as part of the deployment, even with a non-admin deployments user. You should seriously check it out if you haven't done already. – Richard Szalay Mar 05 '13 at 20:32