4
votes

I am using Tfs 2012 to build/deploy our Asp.Net web apps. We have a build definition that builds 5 solutions (.sln files). This is how our MsBuild arguments look like:

/p:DeployOnBuild=True /p:AllowUntrustedCertificate=True /p:DeployIisAppPath="Test"         /p:DeployTarget=MsDeployPublish /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=WMSVC /p:MSDeployServiceUrl="https://{server}:8172/msdeploy.axd" /p:UserName="{user}" /p:Password="{password}"

I need to deploy all 5 sites with Web Deploy using this build definition. They share all the parameters except for the DeployIisAppPath of course. It works for 1 solution, but for more than 1, I need to input a different DeployIisAppPath for each solution, so that each one deploys to the correct site in IIS.

I've checked these questions and other documentation but with no luck yet:

Running a build against multiple projects with different build arguments

Continuous deployment with multiple website projects in solution

How to pass TFS variable to a MSBuild task of the project

TFS2010 Build Definition to Deploy to multiple servers?

I've tried passing the arguments as properties to the {siteName}.Web.csproj for each sln as properties too.

Any help will be appreciated.

2
in case anyone comes across this as I did and is working in VS2010 not 2012. The solution for me was to stop overriding the msbuild argument and simply configure it in the 'Package/Publish web' tab of the web project properties. Under 'web deployment package settings' there's a setting called 'IIS Web site/Application name to use on destination server'. I wonder what the rationale was for removing those settings in 2012.TygerKrash

2 Answers

5
votes

One of the possible ways to do this is to come up with your own set of parameters. Let us say, we call them DeployIisAppPath_One, DeployIisAppPath_Two, etc. Whatever names work for you, as long as they are unique.

Then, make a small edit in every project file that needs to be deployed. In the very first <PropertyGroup> section, add following line. E.g. in first project, add

<DeployIisAppPath Condition="'$(DeployIisAppPath_One)' != ''">$(DeployIisAppPath_One)</DeployIisAppPath>

In second project, simalarly:

<DeployIisAppPath Condition="'$(DeployIisAppPath_Two)' != ''">$(DeployIisAppPath_Two)</DeployIisAppPath>

Repeat for all project that you want to deploy. Now, your new command line would look like this:

msbuild ... /p:DeployIisAppPath_One="MySite/one" /p:DeployIisAppPath_Two="MySite/two" ...
1
votes

You should add Publish Profiles to each Web Project in the solution. After that you can setup the following build arguments:

/p:DeployOnBuild=True
/p:PublishProfile=Development
/p:Password=password-of-your-deploy-user-as-earlier-entered-with-publish-profile

The important one is /p:PublishProfile, this must be the name of the earlier created Publish Profile. Now, when building, MSBuild will lookup the Publish Profile (in this case 'Development') and use this to publish the website.

Complete guide at: http://www.johandorper.com/log/publish-multiple-webprojects-on-build

Hope this helps!