Here is a quick tip on how to generate game build numbers for your C++ games. The only downside to this method is it will always increment the build number even if your project fails to build. But anyway, i hope this little info helps you.
Whoa that’s really neat RyanJon, thanks for sharing!
Wanted to change this to use a relative path (different users with C:\Users[USERNAME]\Documents\Unreal Projects[PROJECTNAME] as the project directory), but a quick glance at RulesCompiler.cs suggested TargetRules doesn’t have a lot of great methods for accessing the project path. The following appears to work (at least for a stock single-module project) until somebody has a better way:
string PROJECT_PATH = RulesCompiler.AllGameFolders;
string GAME_VERSION_FILE = PROJECT_PATH + “/Source/[PROJECTNAME]/Public/GameVersion.h”;
string GAME_BUILD_FILE = PROJECT_PATH + “/Source/GAME_BUILD.txt”;
Awesome stuff thanks!
An update regarding the use of relative paths.
It seems that RulesCompiler class no longer contains property AllGameFolders, however it is possible to retrieve the project directory of the game in this way:
string ProjectDirectory = this.ProjectFile.Directory.FullName;
Where “this” is your project TargetRules class.
Then concatenate the ProjectDirectory string to obtain the absolute path of your GameVersionFile and GameBuildFile.