Skip to content

Commit

Permalink
Update GenBuildInfo to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Timthreetwelve committed Sep 12, 2022
1 parent cd90fbf commit 521e939
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion HWiNFOVSBViewer/HWiNFOVSBViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="powershell -NoProfile -File &quot;$(ProjectDir)Powershell\GenBuildInfo.ps1&quot;" />
<Exec Command="powershell -NoProfile -File &quot;$(ProjectDir)Powershell\GenBuildInfo.ps1&quot; -assemblyName $(AssemblyName) -assemblyVersion $(AssemblyVersion)" />
</Target>

</Project>
4 changes: 2 additions & 2 deletions HWiNFOVSBViewer/Pages/Page3.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@
Grid.Column="0"
Text="Build Date" />
<TextBlock
x:Name="txtBuildDate"
Grid.Row="2"
Grid.Column="1"
Text="{Binding Source={x:Static local:BuildInfo.BuildDateObj}, StringFormat=f}" />
Grid.Column="1"/>
</Grid>
</materialDesign:Card>
</ScrollViewer>
Expand Down
2 changes: 2 additions & 0 deletions HWiNFOVSBViewer/Pages/Page3.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public partial class Page3 : UserControl
public Page3()
{
InitializeComponent();

txtBuildDate.Text = $"{BuildInfo.BuildDateUtc:f} (UTC)";
}

#region License click
Expand Down
27 changes: 19 additions & 8 deletions HWiNFOVSBViewer/Powershell/GenBuildInfo.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
param($outputFile="BuildInfo.cs")
Param(
[Parameter(Mandatory = $true)] [string] $assemblyName,
[Parameter(Mandatory = $true)] [string] $assemblyVersion,
[Parameter(Mandatory = $false)] [string] $outputFile="BuildInfo.cs"
)
Write-Host "GenBuildInfo: Assembly name parameter: $assemblyName"
Write-Host "GenBuildInfo: Assembly version parameter: $assemblyVersion"

$nowUTC = (Get-Date).ToUniversalTime()

$commitID = git rev-parse --short HEAD
if ($commitID.Length -lt 1 ) {
$commitID = "n/a"
}

$buildDate = Get-Date
$gitOutput = git rev-parse --short HEAD
$class =
"// Copyright(c) Tim Kennedy. All Rights Reserved. Licensed under the MIT License.
//
Expand All @@ -10,19 +21,19 @@ $class =
using System;
namespace HWiNFOVSBViewer
namespace $assemblyName
{
public static class BuildInfo
{
public const string CommitIDString = `"$gitOutput`";
public const string CommitIDString = `"$commitID`";
public const string BuildDateString = `"$buildDate`";
public const string BuildDateString = `"$nowUTC`";
public static readonly DateTime BuildDateObj = DateTime.Parse(BuildDateString);
public static readonly DateTime BuildDateUtc = DateTime.SpecifyKind(DateTime.Parse(BuildDateString), DateTimeKind.Utc);
}
}"

Set-Content -Path $outputFile -Value $class

$fullName = Get-Item $outputFile
Write-Host "GenBuildInfo completed. Output written to $fullName"
Write-Host "GenBuildInfo: Output written to $fullName"

0 comments on commit 521e939

Please sign in to comment.