Move build number script to prebuild.ps1

This commit is contained in:
rtm516 2026-03-07 17:41:24 +00:00
parent c7de065434
commit ee6714b75b
No known key found for this signature in database
GPG key ID: 331715B8B007C67A
3 changed files with 35 additions and 11 deletions

View file

@ -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"

View file

@ -1595,6 +1595,12 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"</Command>
<PostBuildEvent>
<Message>Run post-build script</Message>
</PostBuildEvent>
<PreBuildEvent>
<Command>powershell -ExecutionPolicy Bypass -File "$(ProjectDir)prebuild.ps1"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Run pre-build script</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64EC'">
<ClCompile>
@ -1823,6 +1829,12 @@ xcopy /q /y /i /s /e $(ProjectDir)DurangoMedia\CU $(LayoutDir)Image\Loose\CU</C
<DeploymentType>CopyToHardDrive</DeploymentType>
<DeploymentFiles>$(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</DeploymentFiles>
</Deploy>
<PreBuildEvent>
<Command>powershell -ExecutionPolicy Bypass -File "$(ProjectDir)prebuild.ps1"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Run pre-build script</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64EC'">
<ClCompile>

View file

@ -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"