# Building on Windows

## Types of build

In Monaca, Electron applications have two types of build: debug and release. The differences between these types of build are as follows:

| Type of Build     | Description                                                                                          |
| ----------------- | ---------------------------------------------------------------------------------------------------- |
| **Debug Build**   | DevTools are shown by default when the application is launched. It can be closed or opened manually. |
| **Release Build** | There are no DevTools.                                                                               |

{% hint style="info" %}
The built package is unsigned. You might need to [manually sign ](#sign-the-executable-file)the package after downloading.
{% endhint %}

## Step 1: Configure the app

1. From the Monaca Cloud IDE menu, go to **Configure → App Settings for Windows**.
2. Fill in the app information:
   *   Application information:

       | Setting                 | Description                                                                                                                                                                                                                                                                                                                                                 |
       | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
       | Application Name        | The application name                                                                                                                                                                                                                                                                                                                                        |
       | App ID                  | A unique name which will be used when uploading to the Store. It is recommended to use the reverse-domain style (for example, `io.monaca.app_name`) for app ID. Only alphanumeric characters, periods (at least one period must be used) and underscore are allowed. Each segment should be separated by a period and started with an alphabetic character. |
       | Version Number          | The version number of your app. A version number consist of numbers separated by dots (for example, `1.0.0`)                                                                                                                                                                                                                                                |
       | Application Description | The description of your application                                                                                                                                                                                                                                                                                                                         |
   *   Application Icon

       Set an application icon as a PNG. The icon should be at least `512x512` pixels to work across all operating systems.
3. After finishing the configurations, click **Save**.

## Step 2: Build the app

1. From the Monaca Cloud IDE menu, go to **Build → Build App for Windows**.
2.  Select the type of build you want and click the **Start Build** button. The windows release build supports the following build packages:

    | Package  | Description                        |
    | -------- | ---------------------------------- |
    | **nsis** | Generates an NSIS (EXE) installer. |
    | **zip**  | Packs everything into a zip file.  |

![Release Build](https://3091308003-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfWe1U2tFctp8FkP9W8%2F-MfpSWr9CY4ReHmVYfL6%2F-MfpTeQO3eFf89RvfxDl%2Fimage.png?alt=media\&token=fd2f3f6c-73b8-4b3b-8c3c-0cbf94ea4082)

{% hint style="info" %}
There is no build package option for the Windows debug build. The default package is zip.
{% endhint %}

![Debug Build](https://3091308003-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfWe1U2tFctp8FkP9W8%2F-MfpSWr9CY4ReHmVYfL6%2F-MfpTq6mUNFPcPccD6Ao%2Fimage.png?alt=media\&token=8de57227-e051-4b30-a531-6b6310eefd62)

3\. It may take several minutes for the build to complete. Once the build is completed, your application is ready to be downloaded.

![](https://docs.monaca.io/images/cordova_electron/electron_finished_build.jpg)

## Step 3: Install the app

### ZIP package

#### Run the executable file

1. Extract the downloaded zip file.
2. Double click on the executable file. There might be a dialog asking for confirmation before running the application. If so, click **More info**.

![](https://docs.monaca.io/images/cordova_electron/electron_windows_first_click.jpg)

3\. Click **Run anyway**.

![](https://docs.monaca.io/images/cordova_electron/electron_windows_run_anyway.jpg)

#### Sign the executable file

Before proceeding, make sure you have the following prerequisites.

1. Windows Software Develoment Kit (Windows SDK). Please download it from the Microsoft official page. If you are using Windows 10, you can download from this [link.](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)
2. Signing Certificate.

We will be using the `SignTool` command to sign the executable file (`exe`). `SignTool` is included when you install Windows SDK. To sign a file, you just need to open the `Command Prompt` and run:

```
signtool sign /f MyCert.pfx /p "MyPassword" "MyApp.exe"
```

For more information of how to use the `SignTool` command, please refer to the official documentation [here](https://docs.microsoft.com/en-us/windows/win32/seccrypto/using-signtool-to-sign-a-file).

![Signing a file](https://3091308003-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfWe1U2tFctp8FkP9W8%2F-MfpSWr9CY4ReHmVYfL6%2F-MfpUYLsnrZ0nMANGsxo%2Fimage.png?alt=media\&token=3edf5cc2-45b3-4971-aec9-8566f1f68a44)

To verify whether a file is signed, you can run:

```
signtool verify /pa /v "MyApp.exe"
```

![Verifying whether a file is signed](https://3091308003-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfWe1U2tFctp8FkP9W8%2F-MfpSWr9CY4ReHmVYfL6%2F-MfpUgQkoMs4afWXMMPw%2Fimage.png?alt=media\&token=d421e806-f4b6-4e15-848d-13540de41176)

### NSIS (EXE) Installer

#### Install the application

1. Download the NSIS (EXE) file.
2. Double click on the executable file. There might be a dialog asking for confirmation before running the appliation. If so, click **More info** and then **Run anyway**.

![](https://3091308003-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfWe1U2tFctp8FkP9W8%2F-MfpSWr9CY4ReHmVYfL6%2F-MfpUvYHQ2wFNgGldPYJ%2Fimage.png?alt=media\&token=1555faf3-e9e2-449e-bfc9-5d220189ef5a)

3\. The application is installed to your default installation path.

![](https://3091308003-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfWe1U2tFctp8FkP9W8%2F-MfpSWr9CY4ReHmVYfL6%2F-MfpV-bnD4MtwEyM33c1%2Fimage.png?alt=media\&token=92400c7a-516c-456e-915e-740514922647)

#### Create an MSIX package

Before proceeding, please make sure you have the following prerequisites.

1. MSIX Packaging Tool. You can download it from the Microsoft official page. If you are on Windows 10, you can download from this [link](https://www.microsoft.com/en-us/p/msix-packaging-tool/9n5lw3jbcxkf).
2. Signing Certificate

You can use the `MSIX Packaging Tool` to create an MSIX application package from an existing EXE installer. You can refer to the official Microsoft [guideline](https://docs.microsoft.com/en-us/windows/msix/packaging-tool/create-app-package). To use the tool, follow the instructions below:

1. Open the `MSIX Packaging Tool` and choose **Application Package**.

![](https://3091308003-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfWe1U2tFctp8FkP9W8%2F-MfpSWr9CY4ReHmVYfL6%2F-MfpVHrwBvGc7Bnspb86%2Fimage.png?alt=media\&token=9398ff6a-1687-4777-bf9d-4bc0811a57ee)

2\. Browse and choose the downloaded NSIS (EXE) file and check the box under `Sign package` and browse and select your `.pfx` certificate file. If the certificate is protected, type the password in the password field.

![](https://docs.monaca.io/images/cordova_electron/electron_windows_nsis_4.jpg)

3\. Choose the first option **Create package on this computer**.

![](https://docs.monaca.io/images/cordova_electron/electron_windows_nsis_5.jpg)

4\. Fill in the required information. The `Publisher name` will be automatically filled from the uploaded certificate.

![](https://docs.monaca.io/images/cordova_electron/electron_windows_nsis_6.jpg)

5\. Next, go to the `Prepare computer` page that provides options to prepare the computer for packaging. The `MSIX Packaging Tool Driver` is required and the tool will automatically try to enable it.

![](https://docs.monaca.io/images/cordova_electron/electron_windows_nsis_7.jpg)

6\. In the `Installation` page, the tool will test the installer by trying to install the application on your computer.

![](https://docs.monaca.io/images/cordova_electron/electron_windows_nsis_8.jpg)

7\. On the `First launch tasks` page, the entry point should be automatically populated in the list. If it is not, please click the **Browse** button and select the entry point executable file.

![](https://docs.monaca.io/images/cordova_electron/electron_windows_nsis_9.jpg)

8\. Specify the location you would like to save the `MSIX` package.

![](https://docs.monaca.io/images/cordova_electron/electron_windows_nsis_10.jpg)

9\. It might take up to several minutes to create the package. After it is done, it should display something like this:

![](https://docs.monaca.io/images/cordova_electron/electron_windows_nsis_11.jpg)

**Tested environments**

* Windows 10 Pro, Version 1803, OS build 17134.885
* Windows Software Development Kit - Windows 10.0.18362.1
* MSIX Packaging Tool - Version 1.2019.701.0
