Ver Fonte

Make hosting bundle get prodcon runtime versions (#1435)

Justin Kotalik há 7 anos atrás
pai
commit
fc39ea3bec
2 ficheiros alterados com 30 adições e 2 exclusões
  1. 21 0
      scripts/common.psm1
  2. 9 2
      src/Installers/Windows/build.ps1

+ 21 - 0
scripts/common.psm1

@@ -290,3 +290,24 @@ function Get-MSBuildPath {
     }
     return $msbuild
 }
+
+function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) {
+    if ($RemotePath -notlike 'http*') {
+        Copy-Item $RemotePath $LocalPath
+        return
+    }
+
+    $retries = 10
+    while ($retries -gt 0) {
+        $retries -= 1
+        try {
+            Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath
+            return
+        }
+        catch {
+            Write-Verbose "Request failed. $retries retries remaining"
+        }
+    }
+
+    Write-Error "Download failed: '$RemotePath'."
+}

+ 9 - 2
src/Installers/Windows/build.ps1

@@ -14,10 +14,9 @@ param(
     [string]$Runtime64Zip,
     [string]$BuildNumber = 't000',
     [string]$SignType = '',
-
+    [string]$PackageVersionPropsUrl = $null,
     [string]$AccessTokenSuffix = $null,
     [string]$AssetRootUrl = $null,
-
     [switch]$clean
 )
 
@@ -68,6 +67,14 @@ try {
         $msbuildArgs += "-p:DotNetAccessTokenSuffix=$AccessTokenSuffix"
     }
 
+    if ($PackageVersionPropsUrl) {
+        $IntermediateDir = Join-Path $PSScriptRoot 'obj'
+        $PropsFilePath = Join-Path $IntermediateDir 'external-dependencies.props'
+        New-Item -ItemType Directory $IntermediateDir -ErrorAction Ignore | Out-Null
+        Get-RemoteFile "${PackageVersionPropsUrl}${AccessTokenSuffix}" $PropsFilePath
+        $msbuildArgs += "-p:DotNetPackageVersionPropsPath=$PropsFilePath"
+    }
+
     $msbuildArgs += '-t:Build'
 
     Invoke-Block { & $msbuild `