Skip to content

Commit 72dd87a

Browse files
committed
[MERGE #1582 @dilijev] Improve stability of compose_build.ps1.
Merge pull request #1582 from dilijev:compose
2 parents 7e2194a + 69f5316 commit 72dd87a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Build/scripts/compose_build.ps1

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,27 @@ param (
1717
# Aggregate build metadata and produce build.json
1818
#
1919

20-
$outputJsonFile = Join-Path $rootPath "build.json"
20+
$buildJsonFile = Join-Path $rootPath "build.json"
2121
$buildInfo = New-Object System.Object
2222

2323
$changeJson = (Get-ChildItem -Path $rootPath "change.json" -Recurse)[0].FullName
2424
$changeText = (Get-ChildItem -Path $rootPath "change.txt" -Recurse)[0].FullName
25-
Copy-Item -Verbose -Force -Path $changeJson -Destination $rootPath
26-
Copy-Item -Verbose -Force -Path $changeText -Destination $rootPath
25+
26+
# Copy files found in a build metadata directory, protecting against the possibility that this
27+
# build was previously composed and that those files may already be in the destination dir.
28+
if (-not ($changeJson -eq (Join-Path $rootPath "change.json"))) {
29+
Copy-Item -Verbose -Force -Path $changeJson -Destination $rootPath
30+
}
31+
if (-not ($changeText -eq (Join-Path $rootPath "change.txt"))) {
32+
Copy-Item -Verbose -Force -Path $changeText -Destination $rootPath
33+
}
2734

2835
$changeInfo = (Get-Content $changeJson) -join "`n" | ConvertFrom-Json
2936

3037
# Recursively locate ${arch}_${flavor}.json and move to $rootPath.
3138
# This ensures that in the rebuild scenario, we don't have duplication of *.json files
3239
# between the partially-composed root and the metadata directories.
33-
40+
# Exclude change.json and build.json, the results of a previous composition already in the root.
3441
Get-ChildItem -Path $rootPath "*.json" -Recurse `
3542
| ? { -not ($_.Name -in @("change.json", "build.json")) } `
3643
| % { Move-Item -Verbose -Force -Path $_.FullName -Destination $rootPath }
@@ -56,4 +63,4 @@ $buildInfo | Add-Member -type NoteProperty -name change -value $changeInfo
5663
$buildInfo | Add-Member -type NoteProperty -name builds -value $builds
5764

5865
$buildInfo | ConvertTo-Json | Write-Output
59-
$buildInfo | ConvertTo-Json | Out-File $outputJsonFile -Encoding Ascii
66+
$buildInfo | ConvertTo-Json | Out-File $buildJsonFile -Encoding utf8

0 commit comments

Comments
 (0)