I ended up finding a decent solution on the unreal slackers discord
public static void IncrementGameVersion(string ProjectRootPath)
{
string gameIniPath = Path.GetFullPath(Path.Combine(ProjectRootPath, "Config", "DefaultGame.ini"));
bool bFileExists = File.Exists(gameIniPath);
if (!bFileExists)
{
System.Console.WriteLine($"ERROR: Can't find DefaultGame.ini at {gameIniPath}");
return;
}
string projectVersionName = "ProjectVersion";
string projectVersionNameLower = projectVersionName.ToLower();
bool bFoundLine = false;
string[] lines = File.ReadAllLines(gameIniPath);
string newVersion = "1.0.0.0";
for (int i = 0; i < lines.Length; i++)
{
if (lines[i].ToLower().StartsWith(projectVersionNameLower))
{
bFoundLine = true;
string oldVersion = lines[i].Split("=")[1];
string[] oldVersionSplit = oldVersion.Split(".");
string Major = oldVersionSplit[0];
string Minor = oldVersionSplit[1];
string Patch = oldVersionSplit[2];
UInt32 Build = UInt32.Parse(oldVersionSplit[3]);
Build += 1;
newVersion = Major + "." + Minor + "." + Patch + "." + Build;
lines[i] = projectVersionName + "=" + newVersion;
break;
}
}
if (bFoundLine)
{
File.WriteAllLines(gameIniPath, lines);
System.Console.WriteLine("New game version: " + newVersion);
}
else
{
System.Console.WriteLine($"ERROR: {projectVersionName} Not found in DefaultGame.ini at {gameIniPath}");
}
}
That function above is called in my Target.cs file
IncrementGameVersion(ProjectFile?.Directory.ToString());
then insides the game I can do
FString ProductVersion;
if (GConfig->GetString(
TEXT("/Script/EngineSettings.GeneralProjectSettings"),
TEXT("ProjectVersion"),
ProductVersion,
GGameIni
)) {
return ProductVersion;
}
This also works for a custom BuildInfo.ini and BuildDate I added similiarally as above but in other ini files.