Setting up an integrated build and deploy pipeline for LightSwitch applications (part 3)
This is part 3 of a series on using a build server for triggering the deployment of a LightSwitch application, the surrounding website and the application pool.
This article focuses entirely on the TFS build process template that will eventually trigger the deployment.
Just to focus the ideas, recall our proces overview.
Go for a minimalist approach for the build process template
The build process template is the piece of windows workflow that will do the whole handling on the build server. I prefer to keep this as simple as possible by trying to dispatch as soon as possible the more complicated handling to a PowerShell script. The reason why I’m doing this, is because I’m not a big fan of windows workflow.
Create a new build process template, and try to locate the “Compile the Project” block.
Inside this block you will find “RunMsBuild For Project”. We will surround that particular block with 2 extra blocks which are called in the next picture “IfExecuteDeploymentViaWebDeploy”.
But, before doing this, we first need to create a new “build argument”, in such a way we can specify in our build file if we want to deploy via the build:
Step 1: update the BuildArguments
Now, let’s focus on the first block, the one before “Run MsBuild for Project”:
The purpose of this block is to massage the BuildArguments:
We Assign some other text to the MsBuildArguments with the above “IF” statement. The MsBuildArguments should become:
This will make sure we always take the release build and that we trigger the Publish task.
Step 2: Dispatch the handling to a magic power shell script
So, now we focus on the block after “RunMsBuildForProject”:
This block is a more involved, let’s first examine the global picture:
The whole idea here, is to locate a powershell script somewhere in an infrastructure folder on your bu ild server and copy this one to the current build folder.
Create WebDeploy folder
The first block creates a folder called “WebDeploy”. We use this folder to store all our deployment related material.
Assign PowerShell Script Path
The second block will simply assign the powershellscript path to a local variable:
The value of the PowerShellScriptPath variable should become:
Path.Combine(BinariesDirectory, “WebDeploy”, “WebdeployHandling.ps1″)
Copy the PowerShell Script
The next block will copy this file from the infrastructure folder to the current build:
Execute the PowerShell script
The last block is the Execute task:
Here the arguments of this InvokeProcess task which can be complicated to understand:
Since the above might have been difficult to follow, find here the LightSwitchProcessTemplate.
In the next post we’ll tell more about the PowerShell script that will orchestrate the complete deployment handling.
I can assure you, using a powershell script will be a much better approach than trying to incorporate all the deployment handling into the build process template workflow.