summaryrefslogtreecommitdiff
path: root/.packages/microsoft.dotnet.buildtools/3.0.0-preview4-04022-01/lib/init-tools.ps1
diff options
context:
space:
mode:
Diffstat (limited to '.packages/microsoft.dotnet.buildtools/3.0.0-preview4-04022-01/lib/init-tools.ps1')
-rwxr-xr-x.packages/microsoft.dotnet.buildtools/3.0.0-preview4-04022-01/lib/init-tools.ps168
1 files changed, 68 insertions, 0 deletions
diff --git a/.packages/microsoft.dotnet.buildtools/3.0.0-preview4-04022-01/lib/init-tools.ps1 b/.packages/microsoft.dotnet.buildtools/3.0.0-preview4-04022-01/lib/init-tools.ps1
new file mode 100755
index 0000000000..296f5aa431
--- /dev/null
+++ b/.packages/microsoft.dotnet.buildtools/3.0.0-preview4-04022-01/lib/init-tools.ps1
@@ -0,0 +1,68 @@
+ param (
+ [Parameter(Mandatory=$true)][string]$ToolRuntimePath,
+ [Parameter(Mandatory=$true)][string]$DotnetCmd,
+ [Parameter(Mandatory=$true)][string]$BuildToolsPackageDir
+ )
+
+# Override versions in runtimeconfig.json files with highest available runtime version.
+$mncaFolder = (Get-Item $DotnetCmd).Directory.FullName + "\shared\Microsoft.NETCore.App"
+$highestVersion = Get-ChildItem $mncaFolder -Name | Sort-Object BaseName | Select-Object -First 1
+
+foreach ($file in Get-ChildItem $ToolRuntimePath *.runtimeconfig.json)
+{
+ Write-Host "Correcting runtime version of" $file.FullName
+ $text = (Get-Content $file.FullName) -replace "1.1.0","$highestVersion"
+ Set-Content $file.FullName $text
+}
+
+# Make a directory in the root of the tools folder that matches the buildtools version, this is done so
+# the init-tools.cmd (that is checked into each repository that uses buildtools) can write the semaphore
+# marker into this file once tool initialization is complete.
+New-Item -Force -Type Directory (Join-Path $ToolRuntimePath (Split-Path -Leaf (Split-Path $BuildToolsPackageDir)))
+
+# Download the package version props file, if was passed in the environment.
+$packageVersionPropsUrl = $env:PACKAGEVERSIONPROPSURL
+$packageVersionPropsPath = Join-Path $ToolRuntimePath "DownloadedPackageVersions.props"
+
+if ($packageVersionPropsUrl)
+{
+ Write-Host "Downloading package version props from '$packageVersionPropsUrl' to '$packageVersionPropsPath'..."
+
+ # Copied from init-tools.cmd in CoreFX
+ $retryCount = 0
+ $success = $false
+ $proxyCredentialsRequired = $false
+ do
+ {
+ try
+ {
+ $wc = New-Object Net.WebClient
+ if ($proxyCredentialsRequired)
+ {
+ Write-Host "Proxy Authentication Required. Trying to download the package using proxy credentials."
+ [Net.WebRequest]::DefaultWebProxy.Credentials = [Net.CredentialCache]::DefaultNetworkCredentials
+ }
+ $wc.DownloadFile($packageVersionPropsUrl, $packageVersionPropsPath)
+ $success = $true
+ }
+ catch
+ {
+ if ($retryCount -ge 6)
+ {
+ Write-Host "Downloading package failed after retrying $retryCount times."
+ throw
+ }
+ else
+ {
+ $we = $_.Exception.InnerException -as [Net.WebException]
+ $proxyCredentialsRequired = ($we -ne $null -and ([Net.HttpWebResponse]$we.Response).StatusCode -eq [Net.HttpStatusCode]::ProxyAuthenticationRequired)
+ Start-Sleep -Seconds (5 * $retryCount)
+ $retryCount++
+ }
+ Write-Host "Failed to download '$packageVersionPropsPath'. Trying again..."
+ }
+ } while ($success -eq $false);
+
+ Write-Host "Successfully downloaded package version props:"
+ Get-Content $packageVersionPropsPath
+}