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-06-08 12:48:01 +00:00
|
|
|
[string]$Architecture="x64",
|
2016-07-08 23:10:08 +00:00
|
|
|
# This is here just to eat away this parameter because CI still passes this in.
|
2016-07-08 23:40:44 +00:00
|
|
|
[string]$Targets="Default",
|
2016-02-16 20:22:25 +00:00
|
|
|
[switch]$NoPackage,
|
2016-07-12 22:42:27 +00:00
|
|
|
[switch]$NoBuild,
|
2016-07-08 18:54:30 +00:00
|
|
|
[switch]$Help,
|
|
|
|
[Parameter(Position=0, ValueFromRemainingArguments=$true)]
|
|
|
|
$ExtraParameters)
|
2016-02-16 20:22:25 +00:00
|
|
|
|
|
|
|
if($Help)
|
|
|
|
{
|
2016-07-05 22:09:39 +00:00
|
|
|
Write-Host "Usage: .\build.ps1 [-Configuration <CONFIGURATION>] [-Architecture <ARCHITECTURE>] [-NoPackage] [-Help]"
|
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-06-08 12:48:01 +00:00
|
|
|
Write-Host " -Architecture <ARCHITECTURE> Build the specified architecture (x64 or x86 (supported only on Windows), default: x64)"
|
2016-02-16 20:22:25 +00:00
|
|
|
Write-Host " -NoPackage Skip packaging targets"
|
2016-07-12 22:42:27 +00:00
|
|
|
Write-Host " -NoBuild Skip building the product"
|
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-07-05 22:09:39 +00:00
|
|
|
$RepoRoot = "$PSScriptRoot"
|
2016-06-09 22:05:27 +00:00
|
|
|
$env:NUGET_PACKAGES = "$RepoRoot\.nuget\packages"
|
2016-02-02 18:04:50 +00:00
|
|
|
|
2016-02-16 20:04:13 +00:00
|
|
|
if($NoPackage)
|
|
|
|
{
|
|
|
|
$env:DOTNET_BUILD_SKIP_PACKAGING=1
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$env:DOTNET_BUILD_SKIP_PACKAGING=0
|
|
|
|
}
|
|
|
|
|
2016-07-07 23:16:53 +00:00
|
|
|
# Load Branch Info
|
|
|
|
cat "$RepoRoot\branchinfo.txt" | ForEach-Object {
|
|
|
|
if(!$_.StartsWith("#") -and ![String]::IsNullOrWhiteSpace($_)) {
|
|
|
|
$splat = $_.Split([char[]]@("="), 2)
|
|
|
|
Set-Content "env:\$($splat[0])" -Value $splat[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
|
|
|
|
if (!$env:DOTNET_INSTALL_DIR)
|
|
|
|
{
|
|
|
|
$env:DOTNET_INSTALL_DIR="$RepoRoot\.dotnet_stage0\$Architecture"
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(Test-Path $env:DOTNET_INSTALL_DIR))
|
|
|
|
{
|
|
|
|
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
|
|
|
|
}
|
|
|
|
|
2016-07-06 21:45:07 +00:00
|
|
|
& "$RepoRoot\init-tools.ps1" -Architecture $Architecture
|
2016-07-06 19:03:16 +00:00
|
|
|
if($LASTEXITCODE -ne 0) { throw "Failed to install Init Tools" }
|
2016-06-14 08:03:55 +00:00
|
|
|
|
2016-07-07 23:16:53 +00:00
|
|
|
# Put the stage0 on the path
|
|
|
|
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
|
|
|
|
|
|
|
|
# Disable first run since we want to control all package sources
|
|
|
|
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
|
|
|
|
2016-07-12 22:42:27 +00:00
|
|
|
if ($NoBuild)
|
|
|
|
{
|
|
|
|
Write-Host "Not building due to --nobuild"
|
2016-09-23 16:03:57 +00:00
|
|
|
Write-Host "Command that would be run: 'dotnet msbuild build.proj /m /p:Architecture=$Architecture $ExtraParameters'"
|
2016-07-12 22:42:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-23 16:03:57 +00:00
|
|
|
dotnet msbuild build.proj /m /p:Architecture=$Architecture $ExtraParameters
|
2016-07-12 22:42:27 +00:00
|
|
|
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
|
|
|
|
}
|