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 )
{
2016-07-05 15:09:39 -07:00
Write-Host " Usage: .\build.ps1 [-Configuration <CONFIGURATION>] [-Architecture <ARCHITECTURE>] [-NoPackage] [-Help] "
2016-02-16 12:22:25 -08:00
Write-Host " "
Write-Host " Options: "
Write-Host " -Configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug) "
2016-06-08 14:48:01 +02:00
Write-Host " -Architecture <ARCHITECTURE> Build the specified architecture (x64 or x86 (supported only on Windows), default: x64) "
2016-02-16 12:22:25 -08:00
Write-Host " -NoPackage Skip packaging targets "
2016-07-12 15:42:27 -07:00
Write-Host " -NoBuild Skip building the product "
2016-02-16 12:22:25 -08:00
Write-Host " -Help Display this help message "
exit 0
}
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
}
2016-07-07 16:16:53 -07:00
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
2016-11-02 23:01:57 -07:00
if ( ! $env:DOTNET_INSTALL_DIR_PJ )
{
$env:DOTNET_INSTALL_DIR_PJ = " $RepoRoot \.dotnet_stage0PJ\ $Architecture "
}
if ( ! ( Test-Path $env:DOTNET_INSTALL_DIR_PJ ) )
{
mkdir $env:DOTNET_INSTALL_DIR_PJ | Out-Null
}
# Also create an install directory for a post-PJnistic CLI
2016-07-07 16:16:53 -07:00
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-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
2016-12-13 14:15:35 -08:00
# Enable vs test console logging
$env:VSTEST_BUILD_TRACE = 1
$env:VSTEST_TRACE_BUILD = 1
2016-10-25 18:51:41 -05:00
# set the base tools directory
$toolsLocalPath = Join-Path $PSScriptRoot " build_tools "
2017-03-10 13:32:56 -08:00
if ( $env:BOOTSTRAP_INSTALL_DIR )
{
$toolsLocalPath = $env:BOOTSTRAP_INSTALL_DIR
}
2016-10-25 18:51:41 -05:00
$bootStrapperPath = Join-Path $toolsLocalPath " bootstrap.ps1 "
# if the boot-strapper script doesn't exist then download it
if ( ( Test-Path $bootStrapperPath ) -eq 0 )
{
if ( ( Test-Path $toolsLocalPath ) -eq 0 )
{
mkdir $toolsLocalPath | Out-Null
}
# download boot-strapper script
Invoke-WebRequest " https://raw.githubusercontent.com/dotnet/buildtools/master/bootstrap/bootstrap.ps1 " -OutFile $bootStrapperPath
}
# now execute it
2017-04-27 09:29:39 -07:00
& $bootStrapperPath -DotNetInstallBranch release / 2.0 . 0 -RepositoryRoot ( Get-Location ) -ToolsLocalPath $toolsLocalPath -CliLocalPath $env:DOTNET_INSTALL_DIR_PJ -Architecture $Architecture | Out-File ( Join-Path ( Get-Location ) " bootstrap.log " )
2016-10-25 18:51:41 -05:00
if ( $LastExitCode -ne 0 )
{
Write-Output " Boot-strapping failed with exit code $LastExitCode , see bootstrap.log for more information. "
exit $LastExitCode
}
2016-06-14 03:03:55 -05:00
2016-11-02 23:01:57 -07:00
# install the post-PJnistic stage0
$dotnetInstallPath = Join-Path $toolsLocalPath " dotnet-install.ps1 "
2017-04-28 10:57:19 -07:00
Write-Host " $dotnetInstallPath -Channel "" release/2.0.0 "" -Version "" 2.0.0-preview1-005867 "" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture "" $Architecture "" "
Invoke-Expression " $dotnetInstallPath -Channel "" release/2.0.0 "" -Version "" 2.0.0-preview1-005867 "" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture "" $Architecture "" "
2016-11-02 23:01:57 -07:00
if ( $LastExitCode -ne 0 )
{
Write-Output " The .NET CLI installation failed with exit code $LastExitCode "
exit $LastExitCode
}
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 )
{
Write-Host " Not building due to --nobuild "
2016-09-23 09:03:57 -07:00
Write-Host " Command that would be run: 'dotnet msbuild build.proj /m /p:Architecture= $Architecture $ExtraParameters ' "
2016-07-12 15:42:27 -07:00
}
else
{
2017-03-08 09:10:53 -10:00
dotnet msbuild build . proj / p: Architecture = $Architecture / p: GeneratePropsFile = true / t: WriteDynamicPropsToStaticPropsFiles
2017-04-26 23:28:57 -07:00
dotnet msbuild build . proj / m / v: normal / fl / flp : v = diag / p: Architecture = $Architecture $ExtraParameters
2016-07-12 15:42:27 -07:00
if ( $LASTEXITCODE -ne 0 ) { throw " Failed to build " }
}