Azure Devops Pipeline : Enabling CI-CD and generating MSI installer via WIX

In this blog series, We will demonstrate about the capabilities of azure devops for CI-CD in software management.

Following points will be addressed in the document:

  • Basic CI-CD flow with C# software in Azure devops service
  • Generation of MSI installation with “WIX” package installation
  • “Out of the box” tasks in the azure pipeline to schedule timely releases, email the artifacts, generate code coverage and create github release

Technical Specs

We will require some basic hands on knowledge on the following items:

  • XAML and Wix Installer
  • Azure Devops
  • Basic CD-CI knowledge for C# software and git

Prerequisite

We will require access to following items:

  • Microsoft Azure Cloud
  • GitHub repository with C# Code

High Level Design

There are so many discussions around automation and DevOps going on over past a few years. From my point of view, one of the most charming features of DevOps is you can deploy and automate the whole process.

Here is the basic flow of CD using Git and Azure Devops services,

A screenshot of a cell phone

Description automatically generated

For Azure devops to be incorporated in the software, similar to any cloud CD solution we need to drive the pipeline through a single file(azure-pipeline.yml in our case).

There are following items which are useful in the whole pipeline:

  • Stage : showcases the information of which type of pipeline is being executed. E.g : Dev build or Release build
  • Trigger: enables if the pipeline depends on any git branch or any package of a git branch
  • Variables: once defined in the top , can be used across the pipeline in the single run. Useful for generating incremental number in the release.
  • Pool : adding the information on the location or image on software to be executed.
  • Steps : provides the clarity on the pipeline on which cycles does the code needs to go through before final MSI generation
  • Task : various activity which needs to be performed on the software are assigned under task. E.g : running a batch script , msi installation etc.
  • Schedules: In case of time based or scheduled releases, this can be used to generate a cron expression or  user defined scenario

                 

              Azure Pipeline Yaml

Following activities are done in the above sample application.

  1. Triggers when any developers check in the code in master branch
  2. Generating automated incremental release number and stores it in variable
  3. Downloads the latest code from Git Branch
  4. C# Nuget Restore command to download the packages
  5. Building the solution with MSBuild Command via the sln file
  6. Download the Test Case installation package and Code Coverage generation package
  7. Execute the Test Cases via VSTest Suite task and generate the results
  8. Publish the Code Coverage and Test Case result.
  9. Run the MSI Installation Command line to generate exe via “Wix” package.
  10. Upload the MSI package in an artifact
  11. (Optional) Create a Git Release for the code and share the Release Notes.
  12. (Optional) Email the link of the artifact via “send email” task.

We can define cron expression if we need to release the build in a specific timeline.

Here is sample example to be executed daily in 4PM and 12 PM EST and will build from the master branch

Git hub Release

We can release the code build from the pipeline after successful execution and share the release notes to other via email. Following is the task which can be added after the publish of artifact.

WIX Installation

There are many ways of generating MSI packages for windows application. E.g : Vdproj , wix
Definition of MSI : It is an installer package file format used by Windows. Its name comes from the program’s original title, Microsoft Installer, which has since changed to Windows Installer. MSI files are used for installation, storage, and removal of programs. The files are contained in a package, which is used with the program’s client-side installer service, an .EXE file, to open and install the program.

We will showcase the power of “WIX” services in the blog to generate the MSI.

Here is an basic example of the sample WIX file which needs to be present in the source code:

All the tags present in the xml file and explanations for the same can be found in the below link.

https://wixtoolset.org/documentation/

Once we run the below mentioned commands for wix from the pipeline, it will generate the MSI and publish the same.

  • “%WIX%bin\candle” *.wxs -o obj\
  • “%WIX%bin\light” obj\*.wixobj -o bin\CommandLineInstaller.msi

Explanation and Binaries of the above is given in the below link.

https://github.com/wixtoolset/wix3

Conclusion

In the above blog, we have showcased the capabilities of Azure Devops for enabling CD and CI.

There are many other things which can be incorporated with the pipeline and we can use environment and test artifact generation services to handle the releases more efficiently.

Be the first to comment

Leave a Reply

Your email address will not be published.


*