Back to blog

How to build an unsigned Jenkins MSI on your Windows machine

Bruno Verachten
Bruno Verachten
Alexander Brandes
Kevin Martens
Kevin Martens
February 28, 2023

Should you ever need to rebuild a Jenkins MSI on your Windows machine, here is a way to do it.

Pre-requisites

Jenkins WAR file

First, you should download the Jenkins war file that will be inside the MSI file. You can access it from the official Jenkins website or from the Jenkins update center.

Check the Jenkins download page to download the latest weekly version of Jenkins for example. You can always access the direct link to get the latest weekly version, but you won’t necessarily know which version number you are using. Just saying.

Git

There are quite a few ways to install Git on Windows, but the most straightforward way is to see what the official Git website recommends.

Install MSBuild

You can install MSBuild from Visual Studio or from the Build Tools for Visual Studio.

This command line tool is used to build the MSI file.

Install .NET Framework 3.5

You may already have it installed on your machine, but not activated. You can activate it from the Windows Features dialog box.

To access this dialog box, press the keys ⊞ Win + R, then enter the command appwiz.cpl and push enter. Search for

Turn Windows features on or off.

Tick the .NET Framework 3.5 entry and install.

now run Windows Update to check for security updates.

If it is not installed yet, you can install .NET Framework 3.5 from the Windows Features.

Check if you have PowerShell

In recent versions of Windows, PowerShell is already installed and accessible through the terminal application. At the time of writing, the pre-installed version is 5.1.22621.963. You can also install the latest version from the Microsoft Store (7.3.2 at the time of writing).

You could also install PowerShell from GitHub by issuing the following command:

winget show "Microsoft.PowerShell" -s winget

This would give an output similar to:

Found PowerShell [Microsoft.PowerShell]
Version: 7.3.2.0
Publisher: Microsoft Corporation
Publisher Url: https://github.com/PowerShell/PowerShell/
Publisher Support Url: https://github.com/PowerShell/PowerShell/issues
Author: Microsoft Corporation
Moniker: pwsh
Description:
  PowerShell is a cross-platform (Windows, Linux, and macOS) automation and configuration tool/framework that works well with your existing tools and is optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models.
  It includes a command-line shell, an associated scripting language and a framework for processing cmdlets.
Homepage: https://microsoft.com/PowerShell
License: MIT
License Url: https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt
Copyright: Copyright (c) Microsoft Corporation
Copyright Url: https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt
Release Notes Url: https://github.com/PowerShell/PowerShell/releases/tag/v7.3.2
Tags:
  command-line
  cross-platform
  open-source
  powershell
  pwsh
  shell
Installer:
  Installer Type: wix
  Installer Url: https://github.com/PowerShell/PowerShell/releases/download/v7.3.2/PowerShell-7.3.2-win-x64.msi
  Installer SHA256: a4f7d081c5f74bc8d6c75f1dfee382b7fd9335361181748fee590ecdbc96cb26
  Release Date: 2023-01-24

You can see that the latest version is 7.3.2 and that the installer is a .msi file located on GitHub. Just follow the link provided with your browser and install PowerShell from this file once it has downloaded.

Build the MSI

Clone the Jenkins packaging repository

Choose your git tool and clone the Jenkins packaging repository on your machine.

Prepare the build

Open a terminal window and go to the folder where you cloned the repository. For example C:\jenkinsci\packaging\. You now have to declare where you downloaded the Jenkins war file, so the build script can find it.

$env:War = "$env:USERPROFILE\jenkins.war"

If you have previously moved it into your repository clone folder, you can use this command instead:

$env:War = "C:\jenkinsci\packaging\msi\build\jenkins.war"

Build the MSI

Enter the subfolder msi\build and run the following command:

.\build.ps1

You should get an output similar to:

Extracting components
JenkinsVersion = 2.392
Restoring packages before build
All packages listed in packages.config are already installed.
Building MSI
MSBuild version 17.4.0+18d5aef85 for .NET Framework
Build started 01/12/2022 20:53:30.
Project "C:\jenkinsci\packaging\msi\build\jenkins.wixproj" on node 1 (default targets).
SetConstants:
  EncodedVersion = 2.255.3920
Compile:
Skipping target "Compile" because all output files are up-to-date with respect to the input files.
AssignCultures:
  Culture: en-US
Link:
  C:\jenkinsci\packaging\msi\build\packages\WiX.3.11.1\build\..\tools\Light.exe -out C:\jenkinsci\packaging\msi\build\bi
  n\Release\en-US\jenkins-2.392.msi -pdbout C:\jenkinsci\packaging\msi\build\bin\Release\en-US\jenkins-2.392.wixpdb -sw1076 -cultures:en-US -ext C:\Support\users\jenkinsci\packaging\packaging\msi\build\packages\WiX.3.11.1\build\..\tools\\WixUIExtension.dll -ext C:\jenkinsci\packaging\msi\bu  ild\packages\WiX.3.11.1\build\..\tools\\WixNetFxExtension.dll -ext C:\jenkinsci\packaging\msi\build\packages\WiX.3.11.1\build\..\tools\\WixUtilExtension.dll -ext .\msiext-1.5\WixExtensions\WixCommonUIExtension.dll -ext C:\jenkinsci\packaging\msi\build\packages\WiX.3.11.1\build\..\tools\\WixFirewallExtension.dll -fv -loc jenkins_en-US.wxl -spdb -contentsfile obj\Release\jenkins.wixproj.BindContentsFileListen-US.txt -outputsfile obj\Release\jenkins.wixproj.BindOutputs FileListen-US.txt -builtoutputsfile obj\Release\jenkins.wixproj.BindBuiltOutputsFileListen-US.txt -wixprojectfile C:\jenkinsci\packaging\msi\build\jenkins.wixproj obj\Release\jenkins.wixobj
  Windows Installer XML Toolset Linker version 3.11.1.2318
  Copyright (c) .NET Foundation and contributors. All rights reserved.

  jenkins -> C:\jenkinsci\packaging\msi\build\bin\Release\en-US\jenkins-2.392.msi
Done Building Project "C:\jenkinsci\packaging\msi\build\jenkins.wixproj" (default targets).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:08.26

Locate the generated MSI file

The MSI file is located in the .\bin\Release\en-US\ folder. In this folder, you will find the generated MSI file and its sha256 file.

 ls

    Directory: C:\jenkinsci\packaging\msi\build\bin\Release\en-US


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        01/12/2022     20:53      105107456 jenkins-2.392.msi
-a----        01/12/2022     20:53             84 jenkins-2.392.msi.sha256

About the authors

Bruno Verachten

Bruno Verachten

Bruno is a father of two, husband of one, geek in denial, beekeeper, permie and a Developer Relations for the Jenkins project. He’s been tinkering with continuous integration and continuous deployment since 2013, with various products/tools/platforms (Gitlab CI, Circle CI, Travis CI, Shippable, Github Actions, …​), mostly for mobile and embedded development.
He’s passionate about embedded platforms, the ARM&RISC-V ecosystems, and Edge Computing. His main goal is to add FOSS projects and platforms to the ARM&RISC-V architectures, so that they become as boring as X86_64.
He is also the creator of miniJen, the smallest multi-cpu architectures Jenkins instance known to mankind.

Alexander Brandes

Alexander is a Jenkins core maintainer, and the maintainer of the Job Configuration History and Ionicons API plugin.
He is a release team member and actively involved in the process of releasing Jenkins weekly and Long-Term-Support builds.
Alexander enjoys working on open source software in his free time.

Kevin Martens

Kevin Martens

Kevin Martens is part of the CloudBees Documentation team, helping with Jenkins documentation creation and maintenance.