Setting up an integrated build and deploy pipeline for LightSwitch applications (part 3)

Introduction

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.

process

 

 

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”.

Template1

 

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:

Argument

 

Step 1: update the BuildArguments

Now, let’s focus on the first block, the one before “Run MsBuild for Project”:

Template2

 

The purpose of this block is to massage the BuildArguments:

template3

 

We Assign some other text to the MsBuildArguments with the above “IF” statement. The MsBuildArguments should become:

MassageBuildArgs

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”:

Template4

 

This block is a more involved, let’s first examine the global picture:

block2

 

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.

CreateDir

Assign PowerShell Script Path

The second block will simply assign the powershellscript path to a local variable:

 

assign

 

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:

copy

 

copyparams

 

Execute the PowerShell script

The last block is the Execute task:

execute

 

Here the arguments of this InvokeProcess task which can be complicated to understand:

invokeprocessprops

 

 

Conclusion

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.