Part 1 - Create a Jenkins pipeline to deploy Desktop Apps as MSIX: Setup the Jenkins environment
Published Feb 14 2022 06:38 AM 9,503 Views
Microsoft

 

This post is divided in a series of parts to demonstrate how packaging Desktop applications to MSIX using Jenkins.

Parts:

  1. Setup the Jenkins environment: install Jenkins and the required tools.
  2. Packaging a Visual Studio solution: for applications that use Visual Studio IDE, like Windows Forms and WPF.
  3. Packaging a solution developed outside Visual Studio: for applications developed outside VS, i.e., in others IDEs like Eclipse or Visual Studio Code, for Java GUI application.
  4. Packaging using the VB6RegistryTool: despite of the name, the tool can be used by any technology.

In this first part it is demonstrated how to setup the Jenkins environment.

 

Disclaimer

I am not a Jenkins specialist, thus the idea here is to keep it simple and only demonstrate the basics to create a Jenkins Pipeline to package an application to MSIX. This post don't have the pretension to describe the best-practices to setup a Jenkins environment.

 

Requirement

 

 

1 Installing Java JDK

You can skip this section in case you already have Java SDK installed.

Jenkins supports Java 1.8 and 11 or OpenJDK. I am using OpenJDK, as in the Jenkins' Java requirements page it is describes that Jenkins project performs a full test flow with OpenJDK.

 

You can download OpenJDK 11 (Eclipse Temurin JDK more specifically) from the adoptium.net site or through this directly link.

 

Run the OpenJDK setup and click on Next to start the setup:

 

java01.png

 

 

Enable all the options and click on Next again.

 

java02.png

 

 

Click on Install to start installation:

 

java03.png

 

 

Click on Finish to complete the installation:

 

java04.png

 

 

More details about Java requirements here.

 

 

2 Installing Jenkins

You can skip this section, in case you already have a basic installation of Jenkins server.

As we want to package a MSIX package, we need to download Jenkins for Windows. You can download the stable release (LTS - Long-Term Support) here.

 

Run Jenkins installer and click Next to start the setup:

 

jenkins01.png

 

 

Click again on Next, as we are keeping the default folder:

 

jenkins02.png

 

 

The next step is to setup the user account credentials for Jenkins.

 

To keep it simple, I am using my local administrator user that has Log on as a service permission. More information about how to enable service logon here.

Click on Test Credentials to validate the credentials, once validated, click on Next:

 

jenkins03.png

 

 

Now we need to define the port number for the Jenkins service. I am using the default setting that is 8080. Click on Test Port and on Next after having validated the port number:

 

jenkins04.png

 

 

The next step is to define the Java home directory (JDK or JRE).

 

jenkins05.png

 

 

Click on the Change button and provide the Java home directory:

 

jenkins06.png

 

 

Click on Next as we are using the default settings:

 

jenkins07.png

 

 

Finally, click on Install to start installation:

 

jenkins08.png

 

 

Click the Finish button to complete the installation.

 

jenkins09.png

 

 

Launching Jenkins for the first time

Open a browser and pull up port 8080 on localhost, as this is the port number we used previously to setup Jenkins. The getting start screen is presented making reference to the initial admin password:

 

launch01.png

 

 

Copy the password from the file initialAdminPassword displayed on the screen and paste it in the Administrator password field. Then click on the Continue button.

 

launch02.png

 

 

To keep it simple we will install the suggested plugins, as we can come back later and add in more plugins:

 

launch03.png

 

 

As the plugins install, a green check mark appears:

 

launch04.png

 

 

The next step is to create the admin user. Click on *Save and Continue after filling up the fields:

 

launch05.png

 

 

The last step is to set the Jenkins URL. Click Save and Finish to complete the setup.

 

launch06.png

 

 

Click on Start using Jenkins :

 

launch07.png

 

 

You will be prompted to add the Jenkins credentials created earlier:

 

launch08.png

 

 

The default Jenkins page is displayed:

 

launch09.png

 

 

3 Installing Visual Studio 2022

You can skip this step in case you don't have projects on Visual Studio and you are not considering using Windows Application Packaging Project.

Visual Studio will be used in the following scenarios:

  1. build the Windows Forms and the Windows Application Packaging Project projects.
  2. build the Windows Application Packaging Project that will be used to generate the MSIX for a Java GUI application built outside Visual Studio.

You can download Visual Studio 2022 here.

 

vs00.png

 

 

Feel free to install the components that best suit to our scenario.

 

I installed .NET desktop development and Universal Windows Platform since those projects will be used to build a WinForms App and to package it to MSIX through the Windows Application Project.

 

vs01.png

 

 

In addition, make sure that the Windows 10 SDK 10.0.19041.0 is selected, as we are targeting our MSIX package to that Windows 10 operating system build.

 

vs02.png

 

 

Click on Install to start installing Visual Studio.

 

4 Installing Git for Windows

This step is optional in case you don't want to pull the code from GitHub repository.

You can download Git for Windows here.

 

git01.png

 

 

The installation is straightforward and we are use the default settings.

 

Click Next to start the installation:

 

git02.png

 

 

Select the folder where Git should be installed and click on Next to proceed:

 

git03.png

 

 

Feel free to customize your installation. Click Next to proceed:

 

git04.png

 

 

Here you can customize the Git shortcut. Click Next to proceed:

 

git05.png

 

 

Now you can define which editor would you like Git to use. Click Next to proceed:

 

git06.png

 

 

I choose the second option to name the initial name to main. Click Next to proceed:

 

git07.png

 

 

I am using the default recommended option to adjust my PATH environment:

 

git08.png

 

 

I am using the Default first option for OpenSSH, i.e., use ssh.exe that comes with Git:

 

git09.png

 

 

I am using the Default option for HTTPS connections:

 

git10.png

 

 

In this step we need to choose how Git will treat the line ending in text files.

 

git11.png

 

 

Here I choose using Windows' default console window for Git Bash:

 

Git12.png

 

 

I am using the default option for git pull:

 

git13.png

 

 

Now, we need to set the credential helper:

 

git14.png

 

 

I am enabling the default file system caching:

 

git15.png

 

 

Finally, click on Install to install Git for Windows:

 

git16.png

 

 

Click on Finish to complete the installation.

 

git17.png

 

 

Now that Git is installed, switch back to Jenkins, click on Manage Jenkins and Global Tool Configuration to configure the MSBuild plugin:

 

msbuild04.png

 

 

In the Git session, make sure that Jenkins is recognizing the path to Git executable. In my case, Jenkins couldn't find the git.exe:

 

git18.png

 

 

I fixed it by including the full path where Git for Windows is installed:

 

git19.png

 

 

Click on Save to fix the Git path.

 

 

 

Click on Manage Jenkins and Global Tool Configuration to configure the MSBuild plugin:

 

msbuild04.png

 

 

Click on Add MSBuild available in the MSBuild session:

 

msbuild05.png

 

 

 

5 Configure JDK

Switch back to Jenkins, click on Manage Jenkins and Global Tool Configuration to configure the JDK plugin:

 

msbuild04.png

 

 

Scroll-down to the JDK session, click on Add JDK, provide the name JDK 11, uncheck the Install automatically checkbox, and provide the JAVA_HOME path:

 

p1java05.png

 

 

6 Configure Maven

The first step is to download Maven that is available here.

 

Download the Binary zip archive:

 

p1maven03.png

 

 

Extract the zip file in a folder of your preference. I am using the following one:

 

p1maven04.png

 

 

Create a MAVEN_HOME environment variable pointing to your Maven installation folder:

 

p1maven05.png

 

 

Include the %MAVEN_HOME%\bin to the PATH environment:

 

p1maven06.png

 

 

Click on Manage Jenkins and Global Tool Configuration to configure the Maven plugin:

 

msbuild04.png

 

 

Scroll-down to Maven section and click on Add Maven:

 

p1maven07.png

 

 

Provide the name Maven 3.8, uncheck the Install automatically checkbox, provide a value for the MAVEN_HOME, and click on Save:

 

p1maven08.png

 

 

7 GitHub Integration

The following repo msixdemos will be used in our three scenarios.

 

In case you want to use the same repo, my suggestion is that you fork the same so you can have more access and permissions.

Personal access tokens

The first step is click on profile settings:

 

github01.png

 

 

In the Public profile page from GitHub account, click on Developer settings:

 

github02.png

 

 

Click on Personal access tokens and then click on Generate new token button:

 

github03.png

 

 

In the New personal access token page, let's name the new token to Jenkins.

 

We can give it a lot of different permissions, but I want to provide just the permissions needed by Jenkins for GitHub integration.

I have set up the following scopes:

 

github04.png

 

 

Click on the Generate token.

 

The token will only be displayed once, so make sure to save this off:

 

github05.png

 

 

Switch back to Jenkins, click on Manage Jenkins and then Configure System:

 

github06.png

 

Scroll down to the GitHub section, expand the Add GitHub Server and click on GitHub Server:

 

github07.png

 

 

Let's call it to GitHub Connection and under Credentials, let's add a new Jenkins credential:

 

github08.png

 

 

In the Add Credentials page, select the Secret text kind, and paste in the Secret field the personal access token generated previously on GitHub. Name the ID field to GitHubToken and click Add.

 

github09.png

 

 

Under Credentials select the GitHubToken and test the connection.

 

github10.png

 

 

Once it works, click on Save to complete the integration of GitHub with Jenkins.

 

github11.png

 

 

 

In the Part 2 it is demonstrated how creating pipeline on Jenkins.

Co-Authors
Version history
Last update:
‎Mar 24 2022 04:03 AM
Updated by: