1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-02-10 05:30:14 +00:00

1. Reverted Manifest Generation

2. Added PreBuild Event to populate ProductVersion with GIT Commit Hash
This commit is contained in:
Bryan Roe
2022-06-03 20:27:21 -07:00
parent e9839e5305
commit 03d4908956
3 changed files with 85 additions and 5 deletions

View File

@@ -85,8 +85,10 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "MeshCentral Background Service Agent"
VALUE "FileVersion", "0.0.0.0"
VALUE "LegalCopyright", "Apache 2.0 License"
VALUE "ProductName", "MeshCentral Agent"
VALUE "ProductVersion", "0, 0, 0, 0"
END
END

View File

@@ -180,7 +180,6 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PostBuildEventUseInBuild>false</PostBuildEventUseInBuild>
<TargetName>$(ProjectName)64</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoOpenSSL|x64'">
<PostBuildEventUseInBuild>false</PostBuildEventUseInBuild>
@@ -228,7 +227,7 @@
@echo // This file is auto-generated, any edits may be overwritten &gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
git log -1 2&gt;nul | FINDSTR /C:"Date:" | FOR /F "tokens=3,4,5,6,7" %%F in ('findstr "."') do @echo #define SOURCE_COMMIT_DATE "%%I-%%F-%%G %%H%%J" &gt;&gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
git log -1 --format=%%H | FOR /F "tokens=1" %%F in ('findstr "."') do @echo #define SOURCE_COMMIT_HASH "%%F" &gt;&gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
</Command>
powershell -ExecutionPolicy Unrestricted $(ProjectDir)prebuild.ps1 $(ProjectDir)..\Microscript\ILibDuktape_Commit.h $(ProjectDir)MeshService.rc</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>signtool.exe sign /sha1 fd5940d8fd585545614fea6da455f25d224b00c9 /d "MeshService" /du "http://opentools.homeip.net" "$(TargetPath)"</Command>
@@ -316,7 +315,7 @@
@echo // This file is auto-generated, any edits may be overwritten &gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
git log -1 2&gt;nul | FINDSTR /C:"Date:" | FOR /F "tokens=3,4,5,6,7" %%F in ('findstr "."') do @echo #define SOURCE_COMMIT_DATE "%%I-%%F-%%G %%H%%J" &gt;&gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
git log -1 --format=%%H | FOR /F "tokens=1" %%F in ('findstr "."') do @echo #define SOURCE_COMMIT_HASH "%%F" &gt;&gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
</Command>
powershell -ExecutionPolicy Unrestricted $(ProjectDir)prebuild.ps1 $(ProjectDir)..\Microscript\ILibDuktape_Commit.h $(ProjectDir)MeshService.rc</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>signtool.exe sign /sha1 fd5940d8fd585545614fea6da455f25d224b00c9 /d "MeshService" /du "http://opentools.homeip.net" "$(TargetPath)"</Command>
@@ -401,7 +400,7 @@
@echo // This file is auto-generated, any edits may be overwritten &gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
git log -1 2&gt;nul | FINDSTR /C:"Date:" | FOR /F "tokens=3,4,5,6,7" %%F in ('findstr "."') do @echo #define SOURCE_COMMIT_DATE "%%I-%%F-%%G %%H%%J" &gt;&gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
git log -1 --format=%%H | FOR /F "tokens=1" %%F in ('findstr "."') do @echo #define SOURCE_COMMIT_HASH "%%F" &gt;&gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
</Command>
powershell -ExecutionPolicy Unrestricted $(ProjectDir)prebuild.ps1 $(ProjectDir)..\Microscript\ILibDuktape_Commit.h $(ProjectDir)MeshService.rc</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>REM signtool.exe sign /sha1 fd5940d8fd585545614fea6da455f25d224b00c9 /d "MeshService" /du "http://opentools.homeip.net" /t http://timestamp.comodoca.com/authenticode "$(TargetPath)"
@@ -489,7 +488,7 @@
@echo // This file is auto-generated, any edits may be overwritten &gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
git log -1 2&gt;nul | FINDSTR /C:"Date:" | FOR /F "tokens=3,4,5,6,7" %%F in ('findstr "."') do @echo #define SOURCE_COMMIT_DATE "%%I-%%F-%%G %%H%%J" &gt;&gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
git log -1 --format=%%H | FOR /F "tokens=1" %%F in ('findstr "."') do @echo #define SOURCE_COMMIT_HASH "%%F" &gt;&gt; $(ProjectDir)..\microscript\ILibDuktape_Commit.h
</Command>
powershell -ExecutionPolicy Unrestricted $(ProjectDir)prebuild.ps1 $(ProjectDir)..\Microscript\ILibDuktape_Commit.h $(ProjectDir)MeshService.rc</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>REM signtool.exe sign /sha1 fd5940d8fd585545614fea6da455f25d224b00c9 /d "MeshService" /du "http://opentools.homeip.net" /t http://timestamp.comodoca.com/authenticode "$(TargetPath)"

79
meshservice/prebuild.ps1 Normal file
View File

@@ -0,0 +1,79 @@
#Write-Host "Input: $($args[0]) Output: $($args[1])"
#
# Read ILibDuktape_Commit.h into file_data
#
$file_data = Get-Content $($args[0]);
$hash = $null;
$hashdate = $null;
$current = $null;
$updated = $null;
#
# Parse out the GIT Commit Hash and GIT Commit Date, so we can update the resource
#
$tokens = $file_data -split '`n';
for($a=0;$a -lt $tokens.length;++$a)
{
if($tokens[$a].IndexOf('SOURCE_COMMIT_HASH') -gt 0)
{
$hash_tok = $tokens[$a] -split '"';
$hash = $hash_tok[1];
}
if($tokens[$a].IndexOf('SOURCE_COMMIT_DATE') -gt 0)
{
$hash_tok = $tokens[$a] -split '"';
$hashdate = $hash_tok[1];
}
}
#
# Parse the resource file
#
$rc_data = Get-Content $($args[1]);
$i = $rc_data -split '`n';
for($x=0;$x -lt $i.length;++$x)
{
$z = $i[$x] -split '"';
if($z[1] -eq "ProductVersion")
{
#
# Update the ProductVersion
#
$current = $z[3];
$z[3] = "Commit: " + $hash;
$updated = $z[3];
}
if($z[1] -eq "FileVersion")
{
#
# Update File Version
#
$z[3] = $hashdate;
}
$i[$x] = $z -Join '"';
}
#
# Only update MeshService.rc if the values were actually updated
#
if($current -ne $updated)
{
Write-Host "Updated MeshService.rc";
$result = $i -Join [Environment]::NewLine
$result > $($args[1]);
}
else
{
Write-Host "MeshService.rc is already up to date";
}