Return to using local paths for RS publishing (#4764)
authorJuan Hoyos <19413848+hoyosjs@users.noreply.github.com>
Thu, 27 Jun 2024 18:15:04 +0000 (11:15 -0700)
committerGitHub <noreply@github.com>
Thu, 27 Jun 2024 18:15:04 +0000 (11:15 -0700)
eng/release/Scripts/FixupManifestToLocal.ps1

index c5c07a44c3938dff3ecb4ef80b4a51f213da0335..544ecb102fcd9b967900bbe3ac9a24129409e634 100644 (file)
@@ -1,7 +1,7 @@
 param(
   [Parameter(Mandatory=$true)][string] $ManifestPath,
   [Parameter(Mandatory=$true)][string] $StagingPath,
-  [Parameter(Mandatory=$true)][string] $DelegationSasToken,
+  [Parameter(Mandatory=$false)][string] $DelegationSasToken,
   [switch] $help,
   [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
 )
@@ -55,9 +55,31 @@ foreach ($nugetPack in $manifestJson.NugetAssets)
     Add-Member -InputObject $nugetPack -MemberType NoteProperty -Name LocalPath -Value $packagePath
 }
 
+$toolHashToLocalPath = @{}
+
+foreach ($tool in $manifestJson.ToolBundleAssets)
+{
+    $toolPath = Join-Path $StagingPath $tool.PublishRelativePath
+    if (!(Test-Path $toolPath))
+    {
+        Write-Error "Error: unable to find package at '$toolPath'."
+        continue
+    }
+    Add-Member -InputObject $tool -MemberType NoteProperty -Name LocalPath -Value $toolPath
+    $toolHashToLocalPath.Add($tool.Sha512, $toolPath)
+}
+
 foreach ($asset in $manifestJson.PublishInstructions)
 {
-    $asset.FilePath += "?" + $DelegationSasToken
+    $remotePath = $asset.FilePath
+
+    if ($DelegationSasToken -ne "")
+    {
+        $remotePath = "$remotePath?$DelegationSasToken"
+    }
+
+    Add-Member -InputObject $asset -MemberType NoteProperty -Name RemotePath -Value $remotePath
+    $asset.FilePath = $toolHashToLocalPath[$asset.Sha512]
 }
 
 Copy-Item $ManifestPath "$ManifestPath.bak"