Skip to content

Windows Build Instructions

Margen67 edited this page Sep 29, 2020 · 34 revisions

DISCLAIMER: If you are not a developer, building the game from source is not what you want. Use the pre-built Releases. Also, building this on Mac/Linux, while possible, is not covered here. Please let us know if you get it to work!

Building

  1. Get Visual Studio 2019 Community Edition for building TF2. The required installation components are:
    • Desktop development with C++
    • C++ MFC for latest v142 build tools (x86 & x64)
  2. Clone this repo.
  3. Run .\download_libs.bat.
  4. Open .\thirdparty\protobuf-2.5.0\vsprojects\libprotobuf.vcxproj.
  5. Build both the Debug and Release configuration.
  6. Run reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\10.0\Projects\{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" /v DefaultProjectExtension /t REG_SZ /d vcproj /f
  7. Set the environment variables VALVE_NO_AUTO_P4 to true and PreferredToolArchitecture to x64.
  8. Run .\creategameprojects_dev.bat.
    • For Debug, use .\creategameprojects_debug.bat.
  9. Open .\games.sln.
  10. Select all projects. Go to Properties > C/C++ > Language > C++ Language Standard and set language standard to C++17.
  11. Build the VS project.
  12. The executables are placed at ..\game\hl2.exe for the client, and ..\game\srcds.exe for the server.
    • Note: These paths are outside the repository.

Running and Debugging

  1. For the compiled binaries to run, you will need to copy your current TF2 installation to ..\game (relative to your repository, outside of it).
  2. To setup debugging, in Visual Studio, select Client (TF) as the startup project, then go to its Properties > Configuration Properties > Debugging. Set Command to your ..\game\hl2.exe binary, the Command Arguments to -steam -game tf -insecure -novid -nojoy -nosteamcontroller -nohltv -particles 1 -particle_fallback 2 -dev -allowdebug and Working Directory to your game installation folder i.e. ..\game\bin.
    • Note: All the paths here are relative to your copy of the repository (same place where games.sln is located), do not set these values verbatim.
  3. For server, follow the same procedures but choose the Server (TF) project and set the Command to ..\game\srcds.exe. The suggested server launch options are -game tf -console -nomaster -insecure +sv_pure 0 +maxplayers 32 +sv_lan 1 -dev -allowdebug.

See the Valve Developer Wiki for another explanation of the last two steps.

Other launch options to consider:

Option Description
-sw Force windowed mode. (Same as -startwindowed, -window, and -windowed)
-border Enable window borders.
-w WIDTH -h HEIGHT Set the resolution. (Same as -width and -height)
+map MAPNAME Automatically launch a map on startup.

Clone this wiki locally