Share Files Between Projects

From Valve Developer Community
Jump to: navigation, search
Wikipedia - Letter.png
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
Dead End - Icon.png
This article has no links to other VDC articles. Please help improve this article by adding links that are relevant to the context within the existing text.
January 2024


In the creation of a mod, sometimes it is necessary to have a "global" file that both the "client" and "hl" projects can use. To set a file that can be updated from both projects, just follow these steps:

  1. Browse to your mod folder, e.g. C:\MyMods\Mod\ and go to the src directory. In this example, we are going to open the game_shared directory and create a new .cpp file.
  2. Create a text file by right-clicking the folder and clicking New -> Text Document. Rename it mysharedfile.cpp.
  3. Open up the solution file game.sln in VS.NET.
  4. Under the client project create a new folder under Source Files. Name it mod or whatever you prefer.
  5. Right-click the "mod" folder and select Add -> Add Existing Item.
  6. Browse to your C:\MyMod\Mod\src\game_shared directory and find mysharedfile.cpp. Double-click it to add it to your project.
  7. Repeat steps 4-6 for the hl project.

The point of doing this is that both projects now share the same file. This means it does NOT matter which project you use to edit your file, they will be updated and compiled by both. You can use this method for any type of file you want to share.

Note.pngNote:You do not have to put your shared files in game_shared, it's just easier to keep organized that way. Feel free to create a whole new subfolder. Your includes might be a bit different then, e.g. #include <mycustomfolder/header.h>.