Skip to content

Commit 4816fde

Browse files
Merge pull request #1471 from Microsoft/hackVsmanFile
Hack vsman file
2 parents a9bc9b4 + f9ac51f commit 4816fde

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

Nodejs/Setup/BuildRelease.ps1

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,39 @@ function after-build($buildroot, $target) {
243243
}
244244
}
245245

246+
# Fixes hashing information in the .vsman file
247+
function fix-vs-manifest($vsmanFile, $bindir) {
248+
Write-Output "Patching Manifest $vsmanFile"
249+
$json = Get-Content $vsmanFile -raw | ConvertFrom-Json
250+
foreach ($pkg in $json.packages) {
251+
Write-Output "Patching package $($pkg.id)"
252+
253+
# Assume only one payload
254+
$payload = $pkg.payloads[0]
255+
256+
# Remove the _buildInfo block
257+
$payload = $payload | Select-Object * -ExcludeProperty _buildInfo
258+
$pkg.payloads[0] = $payload
259+
260+
# Check that the file exists
261+
$vsixFilename = "$bindir\$($pkg.payloads[0].fileName)"
262+
if (!(Test-Path $vsixFilename)) {
263+
Write-Output "File $vsixFilename does not exist; continuing"
264+
continue
265+
}
266+
267+
# Get its length and hash
268+
$length = (Get-Item $vsixFilename).Length
269+
$sha256 = (Get-Filehash $vsixFilename -Algorithm SHA256).Hash.ToLower()
270+
Write-Output "Hashed $vsixFilename (size $length) to $($sha256.Substring(0, 34))..."
271+
272+
# Set properties
273+
$payload.sha256 = $sha256
274+
$payload.size = $length
275+
}
276+
$json | ConvertTo-Json -depth 100 | Out-File $vsmanFile
277+
}
278+
246279
# This function is invoked after the entire build process but before scorching
247280
function after-build-all($buildroot, $outdir) {
248281
if (-not $release) {
@@ -673,9 +706,17 @@ try {
673706
} } | `
674707
%{ Copy-Item $_.src $_.dest -Force -EA 0; $_ } | `
675708
%{ "Copied $($_.src) -> $($_.dest)" }
709+
710+
$vsmanFile = "$($outdir)\NodejsTools.vsman"
711+
if (Test-Path $vsmanFile) {
712+
Write-Output "Patching VS Manifest $vsmanFile"
713+
fix-vs-manifest $vsmanFile $i.final_msidir
714+
} else {
715+
Write-Output "Skipping VS Manifest patching because $vsmanFile does not exist"
716+
}
676717
}
677718
}
678-
719+
679720
after-build-all $buildroot $outdir
680721

681722
if ($scorch) {

0 commit comments

Comments
 (0)