From c83d94cc6682cb7e05c0469adc06cf55fd25ecc7 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 20 Jan 2022 10:42:04 -0800 Subject: [PATCH] Only update `BuildInfo.cs` if changed This prevents `dotnet` from unnecessarily rebuilding the library, though we lose the precise time and instead only have the date. --- PowerShellEditorServices.build.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 8331c257b..63df05442 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -189,7 +189,7 @@ task CreateBuildInfo -Before Build { $buildOrigin = $env:PSES_BUILD_ORIGIN } - [string]$buildTime = [datetime]::Now.ToString("s", [System.Globalization.CultureInfo]::InvariantCulture) + [string]$buildTime = [datetime]::Today.ToString("s", [System.Globalization.CultureInfo]::InvariantCulture) $buildInfoContents = @" using System.Globalization; @@ -206,7 +206,10 @@ namespace Microsoft.PowerShell.EditorServices.Hosting } "@ - Set-Content -LiteralPath $script:BuildInfoPath -Value $buildInfoContents -Force + if (Compare-Object $buildInfoContents.Split([Environment]::NewLine) (Get-Content $script:BuildInfoPath)) { + Write-Host "Updating Build Info" + Set-Content -LiteralPath $script:BuildInfoPath -Value $buildInfoContents -Force + } } task SetupHelpForTests {