2016-02-02 10:04:50 -08: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 12:04:13 -08:00
[ string ] $Configuration = " Debug " ,
2016-06-08 14:48:01 +02:00
[ string ] $Architecture = " x64 " ,
2016-07-08 16:10:08 -07:00
# This is here just to eat away this parameter because CI still passes this in.
2016-07-08 16:40:44 -07:00
[ string ] $Targets = " Default " ,
2016-02-16 12:22:25 -08:00
[ switch ] $NoPackage ,
2016-07-12 15:42:27 -07:00
[ switch ] $NoBuild ,
2016-07-08 11:54:30 -07:00
[ switch ] $Help ,
[ Parameter ( Position = 0 , ValueFromRemainingArguments = $true ) ]
$ExtraParameters )
2016-02-16 12:22:25 -08:00
if ( $Help )
{
2018-01-17 17:56:34 +00:00
Write-Output " Usage: .\run-build.ps1 [-Configuration <CONFIGURATION>] [-Architecture <ARCHITECTURE>] [-NoPackage] [-NoBuild] [-Help] "
2017-05-26 15:46:56 -07:00
Write-Output " "
Write-Output " Options: "
Write-Output " -Configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug) "
2018-03-25 15:48:16 -04:00
Write-Output " -Architecture <ARCHITECTURE> Build the specified architecture (x64, x86, arm, or arm64 , default: x64) "
2017-05-26 15:46:56 -07:00
Write-Output " -NoPackage Skip packaging targets "
Write-Output " -NoBuild Skip building the product "
Write-Output " -Help Display this help message "
2016-02-16 12:22:25 -08:00
exit 0
}
2016-02-02 10:04:50 -08:00
2018-01-11 21:23:46 +00:00
# The first 'pass' call to "dotnet msbuild build.proj" has a hard-coded "WriteDynamicPropsToStaticPropsFiles" target
# therefore, this call should not have other targets defined. Remove all targets passed in as 'extra parameters'.
2018-01-29 11:48:26 -08:00
if ( $ExtraParameters )
2018-01-11 21:23:46 +00:00
{
2018-01-29 11:48:26 -08:00
$ExtraParametersNoTargets = $ExtraParameters . GetRange ( 0 , $ExtraParameters . Count )
foreach ( $param in $ExtraParameters )
2018-01-11 21:23:46 +00:00
{
2018-01-29 11:48:26 -08:00
if ( ( $param . StartsWith ( " /t: " , [ StringComparison ] :: OrdinalIgnoreCase ) ) -or ( $param . StartsWith ( " /target: " , [ StringComparison ] :: OrdinalIgnoreCase ) ) )
{
$ExtraParametersNoTargets . Remove ( " $param " ) | Out-Null
}
2018-01-11 21:23:46 +00:00
}
}
2016-02-02 10:04:50 -08:00
$env:CONFIGURATION = $Configuration ;
2016-07-05 15:09:39 -07:00
$RepoRoot = " $PSScriptRoot "
2017-03-15 17:04:50 -07:00
if ( ! $env:NUGET_PACKAGES ) {
$env:NUGET_PACKAGES = " $RepoRoot \.nuget\packages "
}
2016-02-02 10:04:50 -08:00
2016-02-16 12:04:13 -08:00
if ( $NoPackage )
{
$env:DOTNET_BUILD_SKIP_PACKAGING = 1
}
else
{
$env:DOTNET_BUILD_SKIP_PACKAGING = 0
}
2017-04-28 11:27:23 -07:00
# Use a repo-local install directory for stage0 (but not the artifacts directory because that gets cleaned a lot
if ( ! $env:DOTNET_INSTALL_DIR )
2016-11-02 23:01:57 -07:00
{
2017-04-28 11:27:23 -07:00
$env:DOTNET_INSTALL_DIR = " $RepoRoot \.dotnet_stage0\ $Architecture "
2016-11-02 23:01:57 -07:00
}
2017-04-28 11:27:23 -07:00
if ( ! ( Test-Path $env:DOTNET_INSTALL_DIR ) )
2016-11-02 23:01:57 -07:00
{
2017-04-28 11:27:23 -07:00
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
2016-11-02 23:01:57 -07:00
}
2016-10-25 18:51:41 -05:00
# Disable first run since we want to control all package sources
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
2017-04-27 12:56:28 -07:00
# Don't resolve shared frameworks from user or global locations
$env:DOTNET_MULTILEVEL_LOOKUP = 0
2018-04-03 16:07:13 -07:00
# Turn off MSBuild Node re-use
$env:MSBUILDDISABLENODEREUSE = 1
2016-12-13 14:15:35 -08:00
# Enable vs test console logging
$env:VSTEST_BUILD_TRACE = 1
$env:VSTEST_TRACE_BUILD = 1
2017-04-28 11:27:23 -07:00
# install a stage0
2018-07-26 16:06:39 -07:00
[ Net.ServicePointManager ] :: SecurityProtocol = [ Net.SecurityProtocolType ] :: Tls12
2018-06-25 22:38:01 -07:00
$dotnetInstallPath = Join-Path $env:DOTNET_INSTALL_DIR " dotnet-install.ps1 "
Invoke-WebRequest -Uri " https://dot.net/v1/dotnet-install.ps1 " -OutFile " $dotnetInstallPath "
2016-10-25 18:51:41 -05:00
2018-03-14 19:04:25 -07:00
$InstallArchitecture = $Architecture
if ( $Architecture . StartsWith ( " arm " , [ StringComparison ] :: OrdinalIgnoreCase ) )
{
$InstallArchitecture = " x64 "
2017-10-17 08:10:22 -07:00
}
2018-03-14 19:04:25 -07:00
2018-07-27 14:55:05 -07:00
Write-Output " $dotnetInstallPath -version "" 3.0.100-preview1-009020 "" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture "" $InstallArchitecture "" "
Invoke-Expression " $dotnetInstallPath -version "" 3.0.100-preview1-009020 "" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture "" $InstallArchitecture "" "
2018-03-14 19:04:25 -07:00
2016-11-02 23:01:57 -07:00
if ( $LastExitCode -ne 0 )
2016-10-25 18:51:41 -05:00
{
2017-10-17 14:32:36 -07:00
Copy-Item -Recurse -Force $env:DOTNET_TOOL_DIR $env:DOTNET_INSTALL_DIR
2016-10-25 18:51:41 -05:00
}
2016-06-14 03:03:55 -05:00
2016-07-07 16:16:53 -07:00
# Put the stage0 on the path
$env:PATH = " $env:DOTNET_INSTALL_DIR ; $env:PATH "
2016-07-12 15:42:27 -07:00
if ( $NoBuild )
{
2017-05-26 15:46:56 -07:00
Write-Output " Not building due to --nobuild "
Write-Output " Command that would be run: 'dotnet msbuild build.proj /m /p:Architecture= $Architecture $ExtraParameters ' "
2016-07-12 15:42:27 -07:00
}
else
{
2018-01-11 21:23:46 +00:00
dotnet msbuild build . proj / p: Architecture = $Architecture / p: GeneratePropsFile = true / t: WriteDynamicPropsToStaticPropsFiles $ExtraParametersNoTargets
2018-07-05 18:01:46 -07:00
dotnet msbuild build . proj / m / v: normal / fl / flp : v = diag / bl / p: Architecture = $Architecture $ExtraParameters
2016-07-12 15:42:27 -07:00
if ( $LASTEXITCODE -ne 0 ) { throw " Failed to build " }
}