none
TFS Build. Deploy multiple websites from a single solution.

    Question

  • Hi

    This is my first post here. Hope somebody can help me.

    I am using VS2010 and Team Build 2010. I am trying to create a build definition that performs a deploy when it finishes compilation. Until now I have had success adding this line to the parameters in MSBuild arguments:

    /p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:MSDeployServiceURL=selva /p:DeployIISAppPath=CruiseSite /p:CreatePackageOnPublish=True /p:MsDeployPublishMethod=RemoteAgent /p:AllowUntrustedCertificated=True /p:UserName=DOMAIN\user /p:Password=******
    

    The problem is now I have a Solution that includes two Web Applications. Since I have to tell msbuild the iisApp at solution level, I can't tell the compiler which iisApp corresponds to each web application project.

    I have tried modifying the build process template xaml, but can't find out how to address individual projects. The build only instructs the compiler to build the solution.

    Is there any Microsoft official solution for this? If not, what's the best approach to specify different deploy configurations for each project in the solution?

    Thank you in advance for your help.

     

    Thursday, August 11, 2011 7:46 AM

Answers

  • Ok, I solved it in a quite simple way:

    1. In the Project Properties of the Web Applications, I set the IIS Web Site/ApplicationName under Package/Publish Web tab to match the destination Web Site in IIS. I also set the option to generate a zip package.
    2. In my build definition I added the following parameters (MSBuild Arguments): /P:DeployOnBuild=True /P:DeployTarget=Package
    3. In the Build Process, I added a new InvokeProcess activity, just below Run MSBuild for Project.
    • DisplayName: Deploy Web Sites
    • Filename: "cmd.exe"
    • Arguments: "/c ""for /R %P in (*.deploy.cmd) do CALL %P /Y /M:<DeployMachineName"""
    • Working Directory: String.Format("{0}/_PublishedWebsites", outputDirectory)

    With this simple steps, the compilation creates a zipped package in the _PublishedWebsites directory (instructed by the /P:DeployOnBuild=True argument). These packages include a batch script to deploy, so I just have to invoke all of the generated *.deploy.cmd scripts.

    Just make sure you:

    • set the <DeployMachineName> to your deployment server
    • set the IIS Web Site/ApplicationNamein the project properties
    • grant admin permissions to the user running the TFS Build Agent

    --- Fernando Arias SQM
    • Marked as answer by ferarias Thursday, August 11, 2011 10:38 AM
    Thursday, August 11, 2011 10:38 AM

All replies

  • Ok, I solved it in a quite simple way:

    1. In the Project Properties of the Web Applications, I set the IIS Web Site/ApplicationName under Package/Publish Web tab to match the destination Web Site in IIS. I also set the option to generate a zip package.
    2. In my build definition I added the following parameters (MSBuild Arguments): /P:DeployOnBuild=True /P:DeployTarget=Package
    3. In the Build Process, I added a new InvokeProcess activity, just below Run MSBuild for Project.
    • DisplayName: Deploy Web Sites
    • Filename: "cmd.exe"
    • Arguments: "/c ""for /R %P in (*.deploy.cmd) do CALL %P /Y /M:<DeployMachineName"""
    • Working Directory: String.Format("{0}/_PublishedWebsites", outputDirectory)

    With this simple steps, the compilation creates a zipped package in the _PublishedWebsites directory (instructed by the /P:DeployOnBuild=True argument). These packages include a batch script to deploy, so I just have to invoke all of the generated *.deploy.cmd scripts.

    Just make sure you:

    • set the <DeployMachineName> to your deployment server
    • set the IIS Web Site/ApplicationNamein the project properties
    • grant admin permissions to the user running the TFS Build Agent

    --- Fernando Arias SQM
    • Marked as answer by ferarias Thursday, August 11, 2011 10:38 AM
    Thursday, August 11, 2011 10:38 AM
  • Hello Fernando,

    Glad to hear you have your issue resolved and thanks for sharing us your solution here.

    Have a nice day.

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 12, 2011 3:12 AM
  • I know this is an old post and was resolved in a clever way, but for anyone interested in another way to skin this cat - I faced the same problem and solved it by customizing the BuildProcessTemplate to take a hash of Build Configurations like "Debug-Website1" paired with the MSBuild arguments containing the deploy parameters.  Then I modified the step in the process that normally applies the arguments to the msbuild call so that it would look up the current project config value in that hash and if it found it, would apply the build arguments, and as a result deploy that project to its target.  In this way I was able to build a single solution with multiple solution configurations in sequence (parallel would be a nice tweak) and push them out to their respective target servers/sites.  Each app was hosted on a pair of load balanced servers, so I deployed to the primary server and then added an msdeploy command line call into the process to perform a content sync from server A to server B.  Worked great.
    Monday, February 13, 2012 3:11 PM