How to build an unsigned Jenkins MSI on your Windows machine

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:jenkinscipackaging.
You now have to declare where you downloaded the Jenkins war file, so the build script can find it.

$env:War = "$env:USERPROFILEjenkins.war"

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

$env:War = "C:jenkinscipackagingmsibuildjenkins.war"

Build the MSI

Enter the subfolder msibuild 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:jenkinscipackagingmsibuildjenkins.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:jenkinscipackagingmsibuildpackagesWiX.3.11.1build..toolsLight.exe -out C:jenkinscipackagingmsibuildbi
  nReleaseen-USjenkins-2.392.msi -pdbout C:jenkinscipackagingmsibuildbinReleaseen-USjenkins-2.392.wixpdb -sw1076 -cultures:en-US -ext C:SupportusersjenkinscipackagingpackagingmsibuildpackagesWiX.3.11.1build..tools\WixUIExtension.dll -ext C:jenkinscipackagingmsibu  ildpackagesWiX.3.11.1build..tools\WixNetFxExtension.dll -ext C:jenkinscipackagingmsibuildpackagesWiX.3.11.1build..tools\WixUtilExtension.dll -ext .msiext-1.5WixExtensionsWixCommonUIExtension.dll -ext C:jenkinscipackagingmsibuildpackagesWiX.3.11.1build..tools\WixFirewallExtension.dll -fv -loc jenkins_en-US.wxl -spdb -contentsfile objReleasejenkins.wixproj.BindContentsFileListen-US.txt -outputsfile objReleasejenkins.wixproj.BindOutputs FileListen-US.txt -builtoutputsfile objReleasejenkins.wixproj.BindBuiltOutputsFileListen-US.txt -wixprojectfile C:jenkinscipackagingmsibuildjenkins.wixproj objReleasejenkins.wixobj
  Windows Installer XML Toolset Linker version 3.11.1.2318
  Copyright (c) .NET Foundation and contributors. All rights reserved.

  jenkins -> C:jenkinscipackagingmsibuildbinReleaseen-USjenkins-2.392.msi
Done Building Project "C:jenkinscipackagingmsibuildjenkins.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 .binReleaseen-US folder.
In this folder, you will find the generated MSI file and its sha256 file.

 ls

    Directory: C:jenkinscipackagingmsibuildbinReleaseen-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

Originally posted on Jenkins Blog
Author:

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *