diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 63ced436f..402f3cb62 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -21,17 +21,6 @@ jobs:
- name: Setup msbuild
uses: microsoft/setup-msbuild@v2
-
- - name: Set BuildVer.h
- shell: bash
- run: |
- cat > Minecraft.Client/Common/BuildVer.h << EOF
- #pragma once
- #define VER_PRODUCTBUILD $GITHUB_RUN_NUMBER
- #define VER_PRODUCTVERSION_STR_W L"${GITHUB_SHA::7} ($GITHUB_REF)"
- #define VER_FILEVERSION_STR_W VER_PRODUCTVERSION_STR_W
- #define VER_NETWORK VER_PRODUCTBUILD
- EOF
- name: Build
run: MSBuild.exe MinecraftConsoles.sln /p:Configuration=Release /p:Platform="Windows64"
diff --git a/Minecraft.Client/Minecraft.Client.vcxproj b/Minecraft.Client/Minecraft.Client.vcxproj
index 4d86f0365..d5cc5c30a 100644
--- a/Minecraft.Client/Minecraft.Client.vcxproj
+++ b/Minecraft.Client/Minecraft.Client.vcxproj
@@ -1595,6 +1595,12 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"
Run post-build script
+
+ powershell -ExecutionPolicy Bypass -File "$(ProjectDir)prebuild.ps1"
+
+
+ Run pre-build script
+
@@ -1823,6 +1829,12 @@ xcopy /q /y /i /s /e $(ProjectDir)DurangoMedia\CU $(LayoutDir)Image\Loose\CUCopyToHardDrive
$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\res=Xbox\res;$(RemoteRoot)=Xbox\AvatarAwards;$(RemoteRoot)\Tutorial=Xbox\Tutorial\Tutorial;$(RemoteRoot)=Xbox\584111F70AAAAAAA;$(RemoteRoot)=Xbox\kinect\speech;$(RemoteRoot)=Xbox\XZP\TMSFiles.xzp
+
+ powershell -ExecutionPolicy Bypass -File "$(ProjectDir)prebuild.ps1"
+
+
+ Run pre-build script
+
diff --git a/Minecraft.Client/prebuild.ps1 b/Minecraft.Client/prebuild.ps1
new file mode 100644
index 000000000..d0ecb828b
--- /dev/null
+++ b/Minecraft.Client/prebuild.ps1
@@ -0,0 +1,23 @@
+$sha = (git rev-parse --short=7 HEAD)
+$ref = (git symbolic-ref HEAD)
+$build = -1
+$suffix = ""
+
+# If we are running in GitHub Actions, use the run number as the build number
+if ($env:GITHUB_RUN_NUMBER) {
+ $build = $env:GITHUB_RUN_NUMBER
+}
+
+# If we have uncommitted changes, add a suffix to the version string
+if (git status --porcelain) {
+ $suffix = "-dev"
+}
+
+@"
+#pragma once
+
+#define VER_PRODUCTBUILD $build
+#define VER_PRODUCTVERSION_STR_W L"$sha$suffix ($ref)"
+#define VER_FILEVERSION_STR_W VER_PRODUCTVERSION_STR_W
+#define VER_NETWORK VER_PRODUCTBUILD
+"@ | Set-Content "Common/BuildVer.h"