Enabling CI-CD and Generating MSI Installations
In this series, we will demonstrate about the capabilities of Azure DevOps for CI-CD in software management.
Join the DZone community and get the full member experience.
Join For FreeIn this blog series, We will demonstrate 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 the 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 the past 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,
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 the following items which are useful in the whole pipeline:
- Stage: showcases the information on 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 is 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
The following activities are done in the above sample application.
- Triggers when any developers check in the code in the master branch
- Generating automated incremental release number and stores it in variable
- Downloads the latest code from Git Branch
- C# Nuget Restore command to download the packages
- Building the solution with MSBuild Command via the sln file
- Download the Test Case installation package and Code Coverage generation package
- Execute the Test Cases via VSTest Suite task and generate the results
- Publish the Code Coverage and Test Case result.
- Run the MSI Installation Command line to generate exe via the “Wix” package.
- Upload the MSI package in an artifact
- (Optional) Create a Git Release for the code and share the Release Notes.
- (Optional) Email the link of the artifact via the “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 at 4 PM and 12 PM EST and will build from the master branch
GitHub Release
We can release the code build from the pipeline after successful execution and share the release notes to others via email. Following is the task which can be added after the publishing of the artifact.
WIX Installation
There are many ways of generating MSI packages for Windows applications. 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 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 a 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 are 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.
Many other things can be incorporated with the pipeline and we can use the environment and test artifact generation services to handle the releases more efficiently.
Published at DZone with permission of Aritra Nag. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments