Skip to content

Setting up Visual Studio for development

Orfeas Zafeiris edited this page Apr 9, 2023 · 5 revisions

1. Install Visual Studio 2022.

First of all, install Visual Studio 2022 with the C++ and game development packages. Any version of VS2022 will work but you might have issues debugging in versions newer than 17.4.5 due to a bug.

2. Create the CMakeUserPresets.json file.

NOTE This is not needed if you generated a project using the mod generator.

In order to be able to easily build, install, and debug the game with the SDK / your mod, you need to create a CMakeUserPresets.json file that points to your game's installation directory. Two sample preset files are provided in this repository as CMakeUserPreses.json-epic_sample and CMakeUserPresets.json-steam_sample for Epic Games Store and Steam users respectively. Copy one of these files to CMakeUserPresets.json, open it, and ensure that GAME_INSTALL_PATH is pointing to the directory where your game is installed. If you are developing a mod, rename ZHMModSDK.dll (Install) in projectTarget to the name of the mod DLL you're developing (eg. MyMod.dll (Install)).

3. Create the .vs/launch.vs.json file.

NOTE This is not needed if you generated a project using the mod generator.

In order to be able to debug the game alongside the SDK / your mod, you must create a launch configuration for Visual Studio. First, create a .vs folder in the project folder (if one doesn't already exist). Then, copy one of the sample launch.vs.json-epic_sample or launch.vs.json-steam_sample files from this repository into .vs/launch.vs.json based on your game's platform (don't forget to remove the sample extension). Open the copied file, and ensure that exe is pointing to your game's executable and cwd to your game's installation folder.

4. Open the project in Visual Studio.

Open the project as a folder in Visual Studio (or right click somewhere in empty space inside the project folder and Open in Visual Studio). It should automatically detect the CMake project and start configuring itself. This might take some time and VS might freeze in the process, so just let it do its thing.

5. Debugging with Visual Studio.

Once the project has loaded, select the x64-Debug-Install configuration and the Hitman 3 target at the top of the IDE, and then just click on it:

Configuration and target selected