How to build an unsigned Jenkins MSI on your Windows machine
PowerShell 7.x building a Jenkins MSI

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.

Thanks a lot to Hervé Le Meur , Alexander Brandes and Kevin Martens for the review and correction.

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        

要查看或添加评论,请登录

Bruno Verachten的更多文章

  • Jenkins' Participation in Hacktoberfest 2024

    Jenkins' Participation in Hacktoberfest 2024

    The Jenkins community is pleased to have participated in this year’s Hacktoberfest, an event focused on fostering…

  • Revamping Jenkins Tutorials: A Journey to Simplicity and Inclusivity

    Revamping Jenkins Tutorials: A Journey to Simplicity and Inclusivity

    Introduction: Transforming Jenkins tutorials Technical tutorials often present challenges to developers, particularly…

  • A glimpse of the future

    A glimpse of the future

    Thanks a lot to Mark Waite and Kevin Martens for their review and suggestions. You’ve all seen it before: the bitter…

    1 条评论
  • How to remove deprecated plugins from Jenkins while using Docker

    How to remove deprecated plugins from Jenkins while using Docker

    Thanks a lot to Kevin Martens for reviewing and correcting this article. The Jenkins plugin ecosystem is highly active,…

  • Building Android apps with Jenkins: release management.

    Building Android apps with Jenkins: release management.

    Thanks a lot to Kevin Martens for reviewing and correcting this article. The previous blog post of this series…

  • Building Android apps with Jenkins: an introduction.

    Building Android apps with Jenkins: an introduction.

    Thanks a lot to Kevin Martens for reviewing and correcting this article. Why is mobile CI/CD special? Found on www.

  • Android and Jenkins: what is the limit?

    Android and Jenkins: what is the limit?

    Thanks a lot to Kevin Martens for his review and suggestions. After reading the title, you may be thinking "Wait, what?…

  • miniJen and RISCV

    miniJen and RISCV

    Thanks a lot to Kevin Martens for his review and suggestions. Short Introduction What is miniJen? It’s the smallest…

    1 条评论
  • miniJen is alive!

    miniJen is alive!

    The Jenkins multi-architecture CPU instance What is that contraption? Nope, it’s not a robot of some sort, it won’t…

  • Intense. Free. Open. Diverse. Benevolent.

    Intense. Free. Open. Diverse. Benevolent.

    FOSDEM is the place to be for open-source developers. And Jenkins project was there, too.

    3 条评论

社区洞察

其他会员也浏览了