@@ -17,20 +17,27 @@ param (
17
17
# Aggregate build metadata and produce build.json
18
18
#
19
19
20
- $outputJsonFile = Join-Path $rootPath " build.json"
20
+ $buildJsonFile = Join-Path $rootPath " build.json"
21
21
$buildInfo = New-Object System.Object
22
22
23
23
$changeJson = (Get-ChildItem - Path $rootPath " change.json" - Recurse)[0 ].FullName
24
24
$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
+ }
27
34
28
35
$changeInfo = (Get-Content $changeJson ) -join " `n " | ConvertFrom-Json
29
36
30
37
# Recursively locate ${arch}_${flavor}.json and move to $rootPath.
31
38
# This ensures that in the rebuild scenario, we don't have duplication of *.json files
32
39
# 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.
34
41
Get-ChildItem - Path $rootPath " *.json" - Recurse `
35
42
| ? { -not ($_.Name -in @ (" change.json" , " build.json" )) } `
36
43
| % { Move-Item - Verbose - Force - Path $_.FullName - Destination $rootPath }
@@ -56,4 +63,4 @@ $buildInfo | Add-Member -type NoteProperty -name change -value $changeInfo
56
63
$buildInfo | Add-Member - type NoteProperty - name builds - value $builds
57
64
58
65
$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