QBO3: Deployment/Publishing

posted Jun 10, 2013, 4:56 PM by Kevin Cassidy   [ updated Nov 5, 2013, 6:25 PM by Eric Patrick ]


In order to assist with faster and more automated deployments, the use of a batch file will be utilized.  This will cut out the repetitive right-click and publish on individual projects and then manipulating the config settings.  In addition to the batch file we will leverage the latest Microsoft Web Deployment "{Configuration Manager}.pubxml" files for publishing.  For each environment you wish to publish to, there should be a corresponding "{Configuration Manager}.pubxml" file.  

An example of the "Local.pubxml" file is as follows:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />

The fields in yellow will change based on environments.  Each target environment will only contain the overrides needed for that server.  Target environments, which correspond to an available Configuration Manager entry in the solution, are as follows:
  • Local
  • DEV
  • DEVIntegration
  • UAT
  • UATIntegration
  • PROD
  • PRODIntegration
In order to publish, you can create a batch file to publish all necessary projects to your target environment.  An example of a batch file that will publish necessary projects from the core solution is as follows:

@echo off

REM Directories without trailing slash
set core=D:\Tags\ADR
set profile=D:\VSPublish\ADR\PublishProfiles

IF [%1] == [] GOTO :InvalidParameters
IF [%2] == [] GOTO :InvalidParameters
IF [%core%] == [] GOTO :InvalidVariables
IF [%profile%] == [] GOTO :InvalidVariables

GOTO :Deploy

@echo Must call with parameters: {Tag} and {Configuration}
@echo Ex. %0 3.00 Local

@echo Must set predefined variables for core and profile

:Deploy IF NOT EXIST Deploy mkdir Log

REM Web Tier
C:\windows\microsoft.net\Framework\v4.0.30319\msbuild "%core%/%1/qbo.Core/Web Tier/qbo.ApplicationWeb/qbo.ApplicationWeb.csproj" /p:VisualStudioVersion=11.0 /p:PublishProfile="%profile%\%2.pubxml" /p:DeployOnBuild=true >> "Log\%2.%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%.log"

C:\windows\microsoft.net\Framework\v4.0.30319\msbuild "%core%/%1/qbo.Core/Web Tier/qbo.AccountingWeb/qbo.AccountingWeb.csproj" /p:VisualStudioVersion=11.0 /p:PublishProfile="%profile%\%2.pubxml" /p:DeployOnBuild=true >> "Log\%2.%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%.log"

C:\windows\microsoft.net\Framework\v4.0.30319\msbuild "%core%/%1/qbo.Core/Web Tier/qbo.AttachmentWeb/qbo.AttachmentWeb.csproj" /p:VisualStudioVersion=11.0 /p:PublishProfile="%profile%\%2.pubxml" /p:DeployOnBuild=true >> "Log\%2.%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%.log"


REM Plugins
C:\windows\microsoft.net\Framework\v4.0.30319\msbuild "%core%/%1/qbo.Core/Plugins/Rebex/qbo.Attachment.Rebex/qbo.Attachment.Rebex.csproj" /p:VisualStudioVersion=11.0 /p:PublishProfile="%profile%\%2.pubxml" /p:DeployOnBuild=true >> "Log\%2.%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%.log"


REM Theme
C:\windows\microsoft.net\Framework\v4.0.30319\msbuild "%core%/%1/qbo.Core/Themes/theme.ADR/theme.ADR.csproj" /p:VisualStudioVersion=11.0 /p:PublishProfile="%profile%\%2.pubxml" /p:DeployOnBuild=true >> "Log\%2.%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%.log"

@echo Log file written to Log\%2.%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%.log
set /p logfile= View log file (y/n)?
IF [%logfile%] == [y] start Log\%2.%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%.log

To utilize the above batch file, the highlighted fields need to be changed to match your environment.

set core={path to your branch or tag root folder}
set profile = {corresponding configuration manager entry}

Note: if you do not have Visual Studio 2012 installed, the references to "/p:VisualStudioVersion=11.0" need to be changed to "/p:VisualStudioVersion=10.0"

When the changes have been made you should be able to use the following command line examples:

"qbo.Deploy.{Theme}.Branch.bat 3.06 DEV"


"qbo.Deploy.{Theme}.Tag.bat 3.06.01 UAT"

Continuous Integration: Publishing without Visual Studio Installed

Publishing without Visual Studio is possible with the Windows SDK for .NET Framework 4 (credit Stack Overflow). Once installed, MSBuild scripts should target Visual Studio 11.0 (2012), even if it's not installed.

The trunk.bat file found in Source > Trunk > qbo.3 > Publish can be used to deploy from trunk. 
  • trunk local: this will deploy all projects to a location specified by local.pubxml
  • trunk A1U3Val: this will deploy all projects to a location specified by a1u3val.pubxml
  • trunk local decision: this will deploy only qbo.DecisionWeb and it's dependencies to a location specified by local.pubxml
You can specify a single core web project to deploy by specifying the root name of the web project as the second parameter.  If there is no second parameter, all projects will be deployed.


Several developers have noted 'no output path' errors using a 'HPC' platform when attempting to run build scripts. This is an artifact of a 'Platform' environment variable from HP conflicting with MSBuild's expected parameters. This can be fixed as follows:
  • Computer > Properties
  • Computer Name > Change Settings
  • Advanced > Environment Variables
  • In the 'System Variables' panel, delete the 'Platform' variable
  • Reboot
Eric Patrick,
Sep 18, 2013, 6:33 PM
Kevin Cassidy,
Jun 10, 2013, 4:56 PM