<commit_before>
This documentation will cover building installers + signing them

This document assumes you have Visual Studio 2017 installed.

# Setup build environment

## Install git

First of all, search for `Git Bash` on your computer to make sure git isn't already installed. If you don't find it, go to [https://git-scm.com/downloads](https://git-scm.com/downloads)

Download the recommended version of git.

Install it.

There are approx. seven configuration screens that follow the license screen. They can be left as they are if you wish.

## Install visual studio 2017 installer extension

Go to `Tools > Extensions` then click on `Online`

Search for "installer projects"

Download "Microsoft Visula Studio 2017 Installer Projects"

Once that's done, close VS2017 and it will automatically install an extension.

## Install safenet client to access smart card

[https://support.comodo.com/index.php?/Knowledgebase/Article/View/1211/66/safenet-download-for-ev-codesigning-certificates](https://support.comodo.com/index.php?/Knowledgebase/Article/View/1211/66/safenet-download-for-ev-codesigning-certificates)

Scroll to the bottom of the page for the download link, then follow instructions on page.

When you install the safenet authentication client, make sure you have all browser windows closed

## Cloning project

Now that you've got all that set up, let's clone the project.

Navigate to and open "Git Bash"

I like to have a workspace where all of my git repositories go. I like this to be "C:\git" but it doesn't really matter.

```
mkdir /c/git
cd /c/git
git clone https://github.com/cloudveiltech/Citadel-Windows.git
cd Citadel-Windows
git submodule update --init
```
## Useful git commands

Run these in Git Bash

### get bleeding edge changes
```
git pull origin master
```

### get a specific tagged version for building
First, make sure that the tag exists in the local repository
```
git fetch --all --tags --prune
```

Not sure what tags are available? Run this for a list.
```
git tag
```

Then checkout the tag by running
```
git checkout tags/v.1.6.9
```

## Building installers
Once you've got the latest code pulled down from the server, go ahead and open the solution file in Visual Studio 2017. `(Project Root)\Citadel.sln`

(If this is your first time doing this, you may need to install the .NET targeting pack for 4.6.2)

On the top bar you'll see options for 'Debug' or 'Release' and 'Any CPU' or 'x86'. Let's change them to 'Release' and 'Any CPU' first.

## New instructions
### x64 Installer

1. Change configuration options to 'Release' and 'Any CPU'
2. Right-click CitadelGUI x64 and click Build.
3. Open SetupPayload64 and scroll down to `System.Net.Http.dll` @TechnikEmpire correct me if we don't need a separate step for SetupPayloa64
4. If there are two entries for `System.Net.Http.dll`, check SourcePath in the properties box (right-click, select properties)
5. If SourcePath does not contain `CloudVeilGUI` delete that entry. There should only be one `System.Net.Http.dll`
6. Right-click Setup x64 and click Rebuild.

### x86 Installer

1. Change configuration options to 'Release' and 'x86'
2. Right-click CitadelGUI x86 and click Build.
3. Open SetupPayload86 and scroll down to `System.Net.Http.dll` @TechnikEmpire correct me if we don't need a separate step for SetupPayloa64
4. If there are two entries for `System.Net.Http.dll`, check SourcePath in the properties box (right-click, select properties)
5. If SourcePath does not contain `CloudVeilGUI` delete that entry. There should only be one `System.Net.Http.dll`
6. Right-click Setup x86 and click Rebuild.

Follow the next instructions to sign the installer.

## Signing installers

### Method 1 - SignInstallers project.
After building both the x86 and x64 installers, right click SignInstallers and click build.

### Method 2 - Manually
1. Open "Developer Command Prompt for VS 2017" `Start Menu > Visual Studio 2017`
2. Go to wherever the installer was built with `cd` on the command prompt. (i.e. `cd C:\git\Citadel-Windows\Installers\Setup x64\bin\Release`)
<commit_msg>Added orca instructions from CreatingInstaller.md<commit_after>
This documentation will cover building installers + signing them

This document assumes you have Visual Studio 2017 installed. You will also need Orca, which you can get in the Windows SDK (sorry, yes, they make you download the entire thing)

# Setup build environment

## Install git

First of all, search for `Git Bash` on your computer to make sure git isn't already installed. If you don't find it, go to [https://git-scm.com/downloads](https://git-scm.com/downloads)

Download the recommended version of git.

Install it.

There are approx. seven configuration screens that follow the license screen. They can be left as they are if you wish.

## Install visual studio 2017 installer extension

Go to `Tools > Extensions` then click on `Online`

Search for "installer projects"

Download "Microsoft Visula Studio 2017 Installer Projects"

Once that's done, close VS2017 and it will automatically install an extension.

## Install safenet client to access smart card

[https://support.comodo.com/index.php?/Knowledgebase/Article/View/1211/66/safenet-download-for-ev-codesigning-certificates](https://support.comodo.com/index.php?/Knowledgebase/Article/View/1211/66/safenet-download-for-ev-codesigning-certificates)

Scroll to the bottom of the page for the download link, then follow instructions on page.

When you install the safenet authentication client, make sure you have all browser windows closed

## Cloning project

Now that you've got all that set up, let's clone the project.

Navigate to and open "Git Bash"

I like to have a workspace where all of my git repositories go. I like this to be "C:\git" but it doesn't really matter.

```
mkdir /c/git
cd /c/git
git clone https://github.com/cloudveiltech/Citadel-Windows.git
cd Citadel-Windows
git submodule update --init
```
## Useful git commands

Run these in Git Bash

### get bleeding edge changes
```
git pull origin master
```

### get a specific tagged version for building
First, make sure that the tag exists in the local repository
```
git fetch --all --tags --prune
```

Not sure what tags are available? Run this for a list.
```
git tag
```

Then checkout the tag by running
```
git checkout tags/v.1.6.9
```

## Building installers
Once you've got the latest code pulled down from the server, go ahead and open the solution file in Visual Studio 2017. `(Project Root)\Citadel.sln`

(If this is your first time doing this, you may need to install the .NET targeting pack for 4.6.2)

On the top bar you'll see options for 'Debug' or 'Release' and 'Any CPU' or 'x86'. Let's change them to 'Release' and 'Any CPU' first.

## New instructions
### x64 Installer

1. Change configuration options to 'Release' and 'Any CPU'
2. Right-click CitadelGUI x64 and click Build.
3. Open SetupPayload64 and scroll down to `System.Net.Http.dll` @TechnikEmpire correct me if we don't need a separate step for SetupPayloa64
4. If there are two entries for `System.Net.Http.dll`, check SourcePath in the properties box (right-click, select properties)
5. If SourcePath does not contain `CloudVeilGUI` delete that entry. There should only be one `System.Net.Http.dll`
6. Go into Detected Dependencies (folder under SetupPayload64) and make sure all DLL's are excluded (right click, hit exclude) There should be a little red circle indicating whether the DLL is excluded.
7. Right-click Setup x64 and click Rebuild.

### x64 Orca instructions
These steps are very important and must be done before signing the installer, otherwise you'll end up needing to sign the installer again.

 1. Open Orca, drop the new `.msi` file in to it to open it.
 2. Find the "Binary" table.
 3. In the "Binary" table, find the "InstallUtil" property and double click the "Data" cell to edit it.
 4. From the now-open file dialog, browse to and select `C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtilLib.dll` and click "Open".
 5. Ensure that "Read binary from filename" is selected.
 6. Click OK, then click save or ctrl+s to save these changes to the MSI file. **This entire process is necessary in order for the MSI to execute the custom actions we use to start up the GUI and spawn the server when installation is complete.** Without doing this, the installer would fail with a bad format exception, because unmodified, it is unable to execute/launch a 64 bit process.
 
### x86 Installer

1. Change configuration options to 'Release' and 'x86'
2. Right-click CitadelGUI x86 and click Build.
3. Open SetupPayload86 and scroll down to `System.Net.Http.dll` @TechnikEmpire correct me if we don't need a separate step for SetupPayloa64
4. If there are two entries for `System.Net.Http.dll`, check SourcePath in the properties box (right-click, select properties)
5. If SourcePath does not contain `CloudVeilGUI` delete that entry. There should only be one `System.Net.Http.dll`
6. Right-click Setup x86 and click Rebuild.

Follow the next instructions to sign the installer.

## Signing installers

### Method 1 - SignInstallers project.
After building both the x86 and x64 installers, right click SignInstallers and click build.

### Method 2 - Manually
1. Open "Developer Command Prompt for VS 2017" `Start Menu > Visual Studio 2017`
2. Go to wherever the installer was built with `cd` on the command prompt. (i.e. `cd C:\git\Citadel-Windows\Installers\Setup x64\bin\Release`)

{'fraction_non_alphanumeric': 0.07860308081873812, 'fraction_numerical': 0.02173454315256383, 'mean_word_length': 4.248615725359912, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1668853', 'n_tokens_mistral': 2865, 'n_tokens_neox': 2613, 'n_words': 1333}