Build instructions
==================

Compiling TortoiseGit is not very difficult, but it requires several steps
to finish, at least the first time.

Unlike other big open source projects, once you have built all the libraries
TortoiseGit depends on, you can use the familiar Visual Studio IDE to build
and debug the binaries. No need to run the build script for every little change.

So don't give up if you read through the next section and all the requirements.
You only have to do this once.

Requirements
------------

First, you need to install the compiler package:

*  You need at least Visual Studio 2022 for
   building the full TortoiseGit package.
   The TortoiseGit teams uses VS2022 Community Edition which is free for open-source
   projects (https://www.visualstudio.com/downloads/).
   Make sure you select the workload "Desktop development with C++" and the following components:
   * VC++ 2022 v143 toolset (x86,x64) (checked by default)
   * Visual C++ ATL-support (x86 and x64)
   * Visual C++ MFC support (x86 and x64)
   * Windows 11 SDK
   * optional: NuGet packet manager (requirement for GoogleTestAdapter, see below)
   * optional: GoogleTestAdapter (if you want to run the tests from within VS)
   * optional: CodeSigning certificate (for Windows 11 start menu extension)
   * For building ARM64 binaries (optional, also requires WiX >= 3.14):
     * VC++ 2022 v143 toolset ARM64 (newest)
     * Visual C++ ATL-support ARM64 (newest)
     * Visual C++ MFC support ARM64 (newest)

Next you might need to install some utilities/programs:
*  If you want to build the MSI installer you need WiX 3.11 (http://wixtoolset.org/releases/)
   and the VS2022 extension (https://github.com/wixtoolset/VisualStudioExtension/releases).
*  If you want to build the installer you need to update the PuTTY binaries by running ext/putty/download.bat
*  For building the docs you need NAnt (http://nant.sourceforge.net/), xsltproc,
   DocBook XSL for DocBook 5.x (https://cdn.docbook.org/release/xsl/),
   for spell checking you need aspell and for building PDF docs you need Apache fop (https://xmlgraphics.apache.org/fop/);
   all these prerequisite tools can be obtained packaged from https://sourceforge.net/projects/tortoisesvn/files/build%20tools/.
   Furthermore, Python 3 (can be installed from the Microsoft Store) is required.
   See doc/readme.txt for more details on building the docs.

In order to not build the Windows 11 start menu extension you need to adjust the following settings:
* Set BuildWindows11ContextmenuExtension to 0 in src/TortoiseGit.settings.props
* Unload the CustomActions11 project in the project explorer

In order to build the Windows 11 start menu extension you need to put your code signing certificate info into:
* src/TortoiseGitSetup/SparsePackage/AppxManifest.xml
* src/identity.manifest

Get external source code
------------------------

TortoiseGit comes with all required code in its repository included or linked as submodules:

Run

    git submodule update --init

to download all linked repositories (submodules) automatically.
Alternatively, you can download submodules when cloning the main project with single command.

    git clone --recursive https://gitlab.com/tortoisegit/tortoisegit.git


After that you might need to apply TortoiseGit specific patches to the external libgit2 repository.
The patches, if any, are located in /ext/ and need to be applied to /ext/libgit2, e.g. using

    cd ext/libgit2
    for %%G in (..\libgit2-*.patch) do ( type %%G | git am --3way )

Building the packages
---------------------

Open TortoiseGit.sln in Visual Studio.
Build all projects.

You can also build TortoiseGit via command line by calling MSBuild
Open Developer Command Prompt for VS20XX

    MSBuild TortoiseGit.sln /p:Configuration=Release;Platform=Win32
    MSBuild TortoiseGit.sln /p:Configuration=Release;Platform=x64

If you want to build the installer package, make sure you build the Win32 configuration before the x64 one
Also, build the docs before the installer packages (or copy existing TortoiseGit_en.chm and TortoiseMerge_en.chm files into the doc/output folder).
