From 7c722b3fe4830bb970fcde4fdca5e29edf90967e Mon Sep 17 00:00:00 2001 From: piotrp Date: Thu, 17 Dec 2015 17:05:05 -0800 Subject: [PATCH] Offline builds on Windows --- scripts/build.ps1 | 9 ++++-- scripts/compile.ps1 | 69 ++++++++++++++++++++++++--------------------- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 2c6e6fac6..024f2d3df 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -4,7 +4,8 @@ # param( - [string]$Configuration="Debug") + [string]$Configuration="Debug", + [string]$Offline=$false) . "$PSScriptRoot\_common.ps1" @@ -35,7 +36,11 @@ if (!$env:DOTNET_BUILD_VERSION) { } Write-Host -ForegroundColor Green "*** Building dotnet tools version $($env:DOTNET_BUILD_VERSION) - $Configuration ***" -& "$PSScriptRoot\compile.ps1" -Configuration:$Configuration +if ($Offline) +{ + Write-Host -ForegroundColor Yellow " - Offline Build -" +} +& "$PSScriptRoot\compile.ps1" -Configuration:$Configuration -Offline:$Offline if (!$?) { Write-Host "Building dotnet tools finished with errors." Exit 1 diff --git a/scripts/compile.ps1 b/scripts/compile.ps1 index 9ec813ac6..24b5d02fc 100644 --- a/scripts/compile.ps1 +++ b/scripts/compile.ps1 @@ -3,7 +3,8 @@ # Licensed under the MIT license. See LICENSE file in the project root for full license information. # -param([string]$Configuration = "Debug") +param([string]$Configuration = "Debug", + [string]$Offline = $false) $ErrorActionPreference="Stop" @@ -23,40 +24,44 @@ Download it from https://www.cmake.org "@ } - # Install a stage 0 - header "Installing dotnet stage 0" - & "$PSScriptRoot\install.ps1" - if (!$?) { - Write-Host "Command failed: $PSScriptRoot\install.ps1" - Exit 1 + if($Offline){ + Write-Host "Skipping Stage 0, Dnx, and Packages dowlnoad: Offline build" } - - # Put stage 0 on the path - $DotNetTools = $env:DOTNET_INSTALL_DIR - if (!$DotNetTools) { - $DotNetTools = "$($env:LOCALAPPDATA)\Microsoft\dotnet" + else { + # Install a stage 0 + header "Installing dotnet stage 0" + & "$PSScriptRoot\install.ps1" + if (!$?) { + Write-Host "Command failed: $PSScriptRoot\install.ps1" + Exit 1 + } + + # Put stage 0 on the path + $DotNetTools = $env:DOTNET_INSTALL_DIR + if (!$DotNetTools) { + $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" + + # 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 + if (!$?) { + Write-Host "Command failed: " dotnet restore "$RepoRoot" --quiet --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64" --no-cache + Exit 1 + } } - # 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" - - # 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 - if (!$?) { - Write-Host "Command failed: " dotnet restore "$RepoRoot" --quiet --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64" --no-cache - Exit 1 - } - - header "Building corehost" pushd "$RepoRoot\src\corehost" try {