diff --git a/eng/native/version/copy_version_files.ps1 b/eng/native/version/copy_version_files.ps1 index 705de544f2e1b1..35a6e1dcc14d4a 100644 --- a/eng/native/version/copy_version_files.ps1 +++ b/eng/native/version/copy_version_files.ps1 @@ -18,7 +18,8 @@ Get-ChildItem -Path "$VersionFolder" -Filter "_version.*" | ForEach-Object { } else { $is_placeholder_file = $true } - if ($is_placeholder_file -and $version_file_contents -ne $current_contents) { + # Only overwrite if the file is a placeholder (or missing) and the content has changed (non empty comparison -> true). + if ($is_placeholder_file -and (Compare-Object $version_file_contents $current_contents)) { $version_file_contents | Set-Content -Path $version_file_destination } } elseif (-not (Test-Path -Path "$RepoRoot\\artifacts\\obj\\$($_.Name)")) {