2

I have an MVC3 application that I deploy to IIS 7.5 using the "Web Publish" feature in Visual Studio. I need to setup a 2nd server that will be hardware load-balanced and will mirror the setup on the 1st server.

I am aware of the Web Farm Framework and that is an option, however I don't like the idea of the controller server being the weakest link in the chain. I think I would rather just use the hardware load balancer to direct traffic.

Is it possible to write a manual Web Deploy script that will target 2 separate servers each time it is run?

user547794
  • 14,263
  • 36
  • 103
  • 152

1 Answers1

1

Here is how I am doing this with TFS:

  1. Create your solution configuration. Select Build -> Configuration Manager. Under Active Solution Configuration drop-down, select New and enter the values (DEV1, DEV2, etc). Make sure configuration column in Project context is DEV1 for DEV1 configuration, etc.

  2. Create a Publish Profile (Build -> Publish ). Create profiles for each of your servers (for example, DEV1 and DEV2). In the Connections tab, select Web Deploy and enter the Server address (with /msdeploy.axd). This server must have web deploy installed (I am using Web Deploy 3.5). Validate your connection to make sure everything is connecting and then next, and close. Don't press on Publish. Once you save this, a new file will be created in your project under Properties > Publishing Profile named something like DEV1.pubxml. This XML file contains all information needed.

  3. Create your web config files for transformations (right click web.config and select Add Config Transform). This will allow you to have different web configuration values based on the type of deployment you do. For example, you can substitute a different value when you publish to PROD for the connection string, etc. You can read more about this here

  4. Open the project file in a text editor (I am using c# so my project file is .csproj). Search for DEV1 as in this example. You will come across a line with DEV1|AnyCPU in it. This will be a a condition in a property of a PropertyGroup tag. Just underneath it, add a PublishProfile tag. Below is a screen-shot:

Adding reference to the Publish Profile

Now you are set. I used TFS Build, and the only thing you have to remember in the Build definition file is to set the correct configuration under Items to Build (under the Process tab).

Items to build setting in the build definition in TFS

You don't need to set the target to build in the MSBuild Arguments field as these values will be picked up from the Publish Profile.

Everything is now set for your to run the build. If you have problems with the build (giving you error about the configuration not being correct), I have answered it here: TFS 2012 Build Definition for web deployment ignores parameters defined in project files

Community
  • 1
  • 1
Aliasger
  • 156
  • 1
  • 8