From 3a2b87a92d8d866503469b5af3859628158b6616 Mon Sep 17 00:00:00 2001 From: Sridhar Periyasamy Date: Fri, 18 Dec 2015 17:04:29 -0800 Subject: [PATCH] Fix to not download Dnx always during a build. --- scripts/_common.ps1 | 3 --- scripts/compile.ps1 | 45 +++++++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/scripts/_common.ps1 b/scripts/_common.ps1 index 968c36e01..adc30cbdd 100644 --- a/scripts/_common.ps1 +++ b/scripts/_common.ps1 @@ -6,11 +6,8 @@ $Rid = "win7-x64" $Tfm = "dnxcore50" -$DnxVersion = "1.0.0-rc1-update1" - $RepoRoot = Convert-Path "$PSScriptRoot\.." $OutputDir = "$RepoRoot\artifacts\$Rid" -$DnxDir = "$OutputDir\dnx" $Stage1Dir = "$OutputDir\stage1" $Stage2Dir = "$OutputDir\stage2" $HostDir = "$OutputDir\corehost" diff --git a/scripts/compile.ps1 b/scripts/compile.ps1 index 8da28f382..c932b8798 100644 --- a/scripts/compile.ps1 +++ b/scripts/compile.ps1 @@ -14,6 +14,36 @@ $ErrorActionPreference="Stop" $StartPath = $env:PATH $StartDotNetHome = $env:DOTNET_HOME +function getDnx() +{ + $DnxPackage = "dnx-coreclr-win-x64.1.0.0-rc1-update1.nupkg" + $DnxVersion = "1.0.0-rc1-16231" + $DnxDir = "$OutputDir\dnx" + $DnxRoot = "$DnxDir/bin" + + # check if the required dnx version is already downloaded + if ((Test-Path "$DnxRoot\dnx.exe")) { + $dnxOut = & "$DnxRoot\dnx.exe" --version + + if ($dnxOut -Match $DnxVersion) { + Write-Host "Dnx version - $DnxVersion already downloaded." + return $DnxRoot + } + } + + # Download dnx to copy to stage2 + Remove-Item -Recurse -Force -ErrorAction Ignore $DnxDir + mkdir -Force "$DnxDir" | Out-Null + + Write-Host "Downloading Dnx version - $DnxVersion." + $DnxUrl="https://api.nuget.org/packages/$DnxPackage" + Invoke-WebRequest -UseBasicParsing "$DnxUrl" -OutFile "$DnxDir\dnx.zip" + + Add-Type -Assembly System.IO.Compression.FileSystem | Out-Null + [System.IO.Compression.ZipFile]::ExtractToDirectory("$DnxDir\dnx.zip", "$DnxDir") + return $DnxRoot +} + try { # Check prereqs @@ -42,22 +72,13 @@ Download it from https://www.cmake.org $DotNetTools = "$($env:LOCALAPPDATA)\Microsoft\dotnet" } - # Download dnx to copy to stage2 - if ((Test-Path "$DnxDir")) { - Remove-Item -Recurse -Force $DnxDir - } - mkdir "$DnxDir" | Out-Null - $DnxUrl="https://api.nuget.org/packages/dnx-coreclr-win-x64.$DnxVersion.nupkg" - Invoke-WebRequest -UseBasicParsing "$DnxUrl" -OutFile "$DnxDir\dnx.zip" - Add-Type -Assembly System.IO.Compression.FileSystem | Out-Null - [System.IO.Compression.ZipFile]::ExtractToDirectory("$DnxDir\dnx.zip", "$DnxDir") - $DnxRoot = "$DnxDir/bin" + $DnxRoot = getDnx # Restore packages header "Restoring packages" - & "$DnxRoot\dnu" restore "$RepoRoot" --quiet --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64" --no-cache + & "$DnxRoot\dnu" restore "$RepoRoot" --quiet --runtime "$Rid" --no-cache if (!$?) { - Write-Host "Command failed: " dotnet restore "$RepoRoot" --quiet --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64" --no-cache + Write-Host "Command failed: " "$DnxRoot\dnu" restore "$RepoRoot" --quiet --runtime "$Rid" --no-cache Exit 1 } }