2016-02-02 18:04:50 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
#
|
|
|
|
|
|
|
|
param(
|
2016-02-16 20:04:13 +00:00
|
|
|
[string]$Configuration="Debug",
|
2016-02-24 02:04:49 +00:00
|
|
|
[string]$Architecture="x64",
|
2016-02-27 02:14:01 +00:00
|
|
|
[string[]]$Targets=@("Default"),
|
2016-02-16 20:22:25 +00:00
|
|
|
[switch]$NoPackage,
|
2016-02-22 23:15:56 +00:00
|
|
|
[switch]$RunInstallerTestsInDocker,
|
2016-02-16 20:22:25 +00:00
|
|
|
[switch]$Help)
|
|
|
|
|
|
|
|
if($Help)
|
|
|
|
{
|
2016-02-27 02:14:01 +00:00
|
|
|
Write-Host "Usage: .\build.cmd [-Configuration <CONFIGURATION>] [-NoPackage] [-Help] [-Targets <TARGETS...>]"
|
2016-02-16 20:22:25 +00:00
|
|
|
Write-Host ""
|
|
|
|
Write-Host "Options:"
|
|
|
|
Write-Host " -Configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
|
2016-02-24 02:04:49 +00:00
|
|
|
Write-Host " -Architecture <ARCHITECTURE> Build the specified architecture (x64 or x86 (supported only on Windows), default: x64)"
|
2016-02-27 02:14:01 +00:00
|
|
|
Write-Host " -Targets <TARGETS...> Comma separated build targets to run (Init, Compile, Publish, etc.; Default is a full build and publish)"
|
2016-02-16 20:22:25 +00:00
|
|
|
Write-Host " -NoPackage Skip packaging targets"
|
2016-02-22 23:15:56 +00:00
|
|
|
Write-Host " -RunInstallerTestsInDocker Runs the .msi installer tests in a Docker container. Requires Windows 2016 TP4 or higher"
|
2016-02-16 20:22:25 +00:00
|
|
|
Write-Host " -Help Display this help message"
|
|
|
|
exit 0
|
|
|
|
}
|
2016-02-02 18:04:50 +00:00
|
|
|
|
|
|
|
$env:CONFIGURATION = $Configuration;
|
|
|
|
|
2016-02-16 20:04:13 +00:00
|
|
|
if($NoPackage)
|
|
|
|
{
|
|
|
|
$env:DOTNET_BUILD_SKIP_PACKAGING=1
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$env:DOTNET_BUILD_SKIP_PACKAGING=0
|
|
|
|
}
|
|
|
|
|
2016-02-22 23:15:56 +00:00
|
|
|
if ($RunInstallerTestsInDocker)
|
|
|
|
{
|
|
|
|
$env:RunInstallerTestsInDocker=1
|
|
|
|
}
|
|
|
|
|
2016-02-02 18:04:50 +00:00
|
|
|
# Load Branch Info
|
|
|
|
cat "$PSScriptRoot\..\branchinfo.txt" | ForEach-Object {
|
|
|
|
if(!$_.StartsWith("#") -and ![String]::IsNullOrWhiteSpace($_)) {
|
|
|
|
$splat = $_.Split([char[]]@("="), 2)
|
|
|
|
Set-Content "env:\$($splat[0])" -Value $splat[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$env:CHANNEL=$env:RELEASE_SUFFIX
|
|
|
|
|
|
|
|
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
|
|
|
|
if (!$env:DOTNET_INSTALL_DIR)
|
|
|
|
{
|
2016-02-24 02:04:49 +00:00
|
|
|
$env:DOTNET_INSTALL_DIR="$PSScriptRoot\..\.dotnet_stage0\Windows\$Architecture"
|
2016-02-02 18:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(Test-Path $env:DOTNET_INSTALL_DIR))
|
|
|
|
{
|
|
|
|
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install a stage 0
|
|
|
|
Write-Host "Installing .NET Core CLI Stage 0 from beta channel"
|
2016-03-14 18:54:15 +00:00
|
|
|
& "$PSScriptRoot\obtain\install.ps1" -Channel $env:CHANNEL -Architecture $Architecture -Verbose
|
2016-02-02 18:04:50 +00:00
|
|
|
|
|
|
|
# Put the stage0 on the path
|
2016-03-21 19:40:52 +00:00
|
|
|
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
|
2016-02-02 18:04:50 +00:00
|
|
|
|
|
|
|
# Restore the build scripts
|
|
|
|
Write-Host "Restoring Build Script projects..."
|
|
|
|
pushd $PSScriptRoot
|
2016-03-18 00:09:25 +00:00
|
|
|
dotnet restore --disable-parallel
|
2016-02-02 18:04:50 +00:00
|
|
|
if($LASTEXITCODE -ne 0) { throw "Failed to restore" }
|
|
|
|
popd
|
|
|
|
|
|
|
|
# Publish the builder
|
|
|
|
Write-Host "Compiling Build Scripts..."
|
2016-03-01 23:35:32 +00:00
|
|
|
dotnet publish "$PSScriptRoot\dotnet-cli-build" -o "$PSScriptRoot/dotnet-cli-build/bin" --framework netstandardapp1.5
|
2016-02-02 18:04:50 +00:00
|
|
|
if($LASTEXITCODE -ne 0) { throw "Failed to compile build scripts" }
|
|
|
|
|
|
|
|
# Run the builder
|
|
|
|
Write-Host "Invoking Build Scripts..."
|
2016-02-16 20:04:13 +00:00
|
|
|
Write-Host " Configuration: $env:CONFIGURATION"
|
2016-02-27 02:14:01 +00:00
|
|
|
& "$PSScriptRoot\dotnet-cli-build\bin\dotnet-cli-build.exe" @Targets
|
2016-02-02 18:04:50 +00:00
|
|
|
if($LASTEXITCODE -ne 0) { throw "Build failed" }
|