Skip to content

Windows Build Instructions

Margen67 edited this page Nov 4, 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 repository.
  3. Run .\download_libs.bat.
    • Note: This requires curl. (included with Windows 10 build 17063 or later)
  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 following environment variables:
    Name Value
    VALVE_NO_AUTO_P4 1
    PreferredToolArchitecture 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:
  • Client (TF) (hl2.exe):
    1. Right click Client (TF), go to Properties > Configuration Properties > Debugging, and set the following:
      Command $(SolutionDir)..\game\hl2.exe
      Command Arguments -steam -game tf -insecure -novid -nojoy -nosteamcontroller -particle_fallback 2 -allowdebug
      Working Directory $(SolutionDir)..\game
      • Note: Paths here are relative to your copy of the repository (same place where games.sln is located).
    2. Right click Client (TF) and choose Set as Startup Project.
  • Server (TF) (srcds.exe):
    1. Right click Server (TF), go to Properties > Configuration Properties > Debugging, and set the following:
      Command $(SolutionDir)..\game\srcds.exe
      Command Arguments -game tf -console -nomaster -insecure +sv_pure 0 -maxplayers 32 +sv_lan 1 -allowdebug
      Working Directory Same as Client (TF).
      • Note: Paths here are relative to your copy of the repository (same place where games.sln is located).
    2. Right click Server (TF) and choose Set as Startup Project.

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