提交 f9ccbbdd 编写于 作者: J Jared Parsons

Simplify the Nuget.Exe download

Now that we are not tied to roslyn-internal anymore it's possible to
simplify this action a bit:

- Remove the separate script as it's not necessary and can be easily
inlined
- Remove the copy to the root of the source tree. Not necessary anymore
as all our scripts use the returned variable.
上级 1a36abc6
......@@ -107,12 +107,31 @@ function Exec-Script([string]$script, [string]$scriptArgs = "") {
Exec-Command "powershell" "-noprofile -executionPolicy RemoteSigned -file `"$script`" $scriptArgs"
}
# Ensure that NuGet is installed and return the path to the
# executable to use.
function Ensure-NuGet() {
Exec-Block { & (Join-Path $PSScriptRoot "download-nuget.ps1") } | Out-Host
$nuget = Join-Path $repoDir "NuGet.exe"
return $nuget
$nugetVersion = "4.1.0"
$toolsDir = Join-Path $binariesDir "Tools"
Create-Directory $toolsDir
$destFile = Join-Path $toolsDir "NuGet.exe"
$versionFile = Join-Path $toolsDir "NuGet.exe.version"
# Check and see if we already have a NuGet.exe which exists and is the correct
# version.
if ((Test-Path $destFile) -and (Test-Path $versionFile)) {
$scratchVersion = Get-Content $versionFile
if ($scratchVersion -eq $nugetVersion) {
return $destFile
}
}
Write-Host "Downloading NuGet.exe"
$webClient = New-Object -TypeName "System.Net.WebClient"
$webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/v$nugetVersion/NuGet.exe", $destFile)
$nugetVersion | Out-File $versionFile
return $destFile
}
# Ensure a basic tool used for building our Repo is installed and
......
param ([string]$nugetVersion = "4.1.0")
Set-StrictMode -version 2.0
$ErrorActionPreference="Stop"
try {
. (Join-Path $PSScriptRoot "build-utils.ps1")
$scratchDir = Join-Path $binariesDir "NuGet"
Create-Directory $scratchDir
$destFile = Join-Path $repoDir "NuGet.exe"
$scratchFile = Join-Path $scratchDir "NuGet.exe"
$versionFile = Join-Path $scratchDir "version.txt"
# Check and see if we already have a NuGet.exe which exists and is the correct
# version.
if ((Test-Path $destFile) -and (Test-Path $scratchFile) -and (Test-Path $versionFile)) {
$destHash = (Get-FileHash $destFile -algorithm MD5).Hash
$scratchHash = (Get-FileHash $scratchFile -algorithm MD5).Hash
$scratchVersion = Get-Content $versionFile
if (($destHash -eq $scratchHash) -and ($scratchVersion -eq $nugetVersion)) {
Write-Host "Using existing NuGet.exe at version $nuGetVersion"
exit 0
}
}
Write-Host "Downloading NuGet.exe"
$webClient = New-Object -TypeName "System.Net.WebClient"
$webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/v$nugetVersion/NuGet.exe", $scratchFile)
$nugetVersion | Out-File $versionFile
Copy-Item $scratchFile $destFile
exit 0
}
catch [exception] {
Write-Host $_.Exception
exit 1
}
......@@ -59,7 +59,7 @@ try {
$list = Get-Content (Join-Path $PSScriptRoot "files.txt")
$dropPath = "\\cpvsbuild\drops\VS\$branch\raw\$version\binaries.x86ret\bin\i386"
$nuget = Join-Path $PSScriptRoot "..\..\..\nuget.exe"
$nuget = Join-Path $PSScriptRoot "..\..\..\Binaries\Tools\nuget.exe"
$fakeSign = Join-Path (Get-PackageDir "FakeSign") "Tools\FakeSign.exe"
$shortVersion = $version.Substring(0, $version.IndexOf('.'))
......
......@@ -23,7 +23,7 @@ echo "= Clearing nuget caches"
echo "==============================================="
echo ""
# & $ScriptDir\..\..\..\nuget.exe locals all -clear
# & $ScriptDir\..\..\..\Binaries\Tools\nuget.exe locals all -clear
echo ""
echo "==============================================="
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册