Continuous Deployment of an XBAP application

Posted by InRelease - February 05, 2013

header-picture

Normal publishing methods to deploy XBAP application are not well suited for best practices of release management. XBAP applications are usually published from Visual Studio (or from TFS Team Build) to one specific environment. Multiple publishing of the same build to different environments becomes problematic because of the hashing contained in the manifest files. This document will described how publishing to multiple environments can be achieved using InRelease.

Prerequisites

Here are some prerequisites in order to make this automated deployment work. In InRelease, a Release Path has already been created and is ready to be used.

Publishing XBAP application through the build process

To be able to deploy an XBAP application, we need the build server to do the same logic that is done when publishing the application from Visual Studio. We therefore need to modify the build template used to build the application.

1. Navigate to the activity named Run MSBuild for project at this location:

1.png2.png

2. Change the property CommandLineArguments to

String.Format("/p:SkipInvalidConfigurations=true /Target:Publish;Build /p:PublishDir=""{0}/PublishedFiles/"" {1}", outputDirectory, MSBuildArguments)

3. Set up a build definition that uses the modified build template. Edit Build Definition, select Process, click New…, Select an existing XAML file, and Browse to the newly defined xaml file.

3.png

4. If you use a Deployement Web Page, more changes needs to be done to the build template (see next two sections). Else, follow the next two sections before triggering a build.

Publishing Dependencies (Optional)

In an XBAP project, it is possible to identify different dependencies and ask the build process to generate a setup.exe file. This is accomplished automatically when building if the following option was checked.

4.png

When building the project, it will generate a setup.exe file. In this case, the command executed by the XBAP Deployer tool will have to include a parameter identifying the setup URL (see section Tool, parameter -url)

Deployment Web Page (Optional)

While publishing the XBAP project through Visual Studio, it is possible to generate a deployment web page. This is part in the publishing step done by Visual Studio. Since we now process this step in TFS, the deployment web page cannot be produced during the TFS build. It will need to be already part of the solution in order to have it in the drop folder. Follow these steps to do so.

1. Generate a deployment web page file for the project once. To achieve this, you will need to set your Publish options like shown in the following image.

5.png

2. Publish the application and the file will be available from the published folder.

6.png

3. In Windows explorer, add a folder named Publish at your solution level and add the generated deployment web page file in it.

7.png

4. Add a corresponding solution folder named Publish. Select Add an Existing Item and add the file in it.

8.png

5. Modify the build template by navigating to this location :

9.png10.png

 

6. Add an InvokeProcess task after If BuildSettings.HasProjectsToBuild.

11.png

7. Set the following properties for the newly added task:

Arguments: """" + Path.Combine(SourcesDirectory, "Publish") + """ """ + Path.Combine(BinariesDirectory, "PublishedFiles") + """"

Display Name: Copy deployment web page file

FileName: "xcopy"

Note that the arguments set in the Copy action is based on the build definition used having its Source Control Folder set at the solution root and the Build Agent Folder at the root of the source directory:

12.png

Working with a Signed Manifest (Optional)

If you need to have your manifests signed after publishing the application, the following steps will need to be done:

1. Add the certificate file in your XBAP project’s root (.pfx file).

13.png

2. In the properties of this file, set the following:

13.1.png

3. Use the –cf arguments in the XBAP Deployer tool (see section Tool).

InRelease Configuration

Now that the TFS Drop Location contains all the needed files, we can configure the necessary InRelease objects to be able to deploy the database.

Components

In order to automate the deployment of an XBAP package, a component is required. This component will use InRelease’s XBAP Deployer tool to modify the configuration files, resign the manifests if needed and finally rehash the manifests to make sure they are kept valid.

1. Create a new component (Configure Apps | Components, click New).

2. In Source tab, select the source where the XBAP application is located. Also, in the field Path to package, input “PublishedFiles” to indicate that only this sub-folder is to be copied over to the InRelease Deployer temp location when deploying that component.

3. In Deployment tab, select the Tool XBAP Deployer.

4. Verify/adjust the Arguments (see previous section). For example:

-pn __ProjectName__ -d __Installation Path__

5. Set the Variable Replacement Mode to Before Installation if any variables are used as token in your configuration files. Configuration variables need to be replaced prior to running the XBAP Deployer tool since rehashing (done by the tool) needs to happen after the configuration files have been modified.

6. The File Extension Filter is set to the matching pattern needed. Be careful here since an XBAP publishing action (if configured using default options) adds the extension .deploy to all files contained in the package. If you are using this convention, add it as well in the File Extension Filter.

15.png

Release Template

Now that the component is created, we will use it within an Release Template.

1. Create a new Release Template (Configure Apps | Release Templates, click New).

2. Select the Build Definition that was created earlier and then Create.

3. In the toolbox, right-click on the Component link, select Add and then Link the component just created.

4. In the Deployment Sequence section, add the new component in the destination server and adjust the configuration variables values.

Deployment

A Release can then be created and started. This will deploy the XBAP package to the destination folder defined by the Installation Path configuration variable.

Topics: InRelease


Recent Posts

InCycle Named Azure Data Explorer (ADX) Partner

read more

OpsHub & InCycle Help Top Medical Device Company Accelerate Innovation

read more

InCycle Continues to Lead, Recognized by Microsoft for Industry Innovation. Earns Impact Award.

read more