Skip to content

Commit

Permalink
Bootstrapper improvements. (#1423)
Browse files Browse the repository at this point in the history
    Replace & PS operator with custom process launcher. The & operator does not allow to send colorized output to the host without polluting function return value.
    Automatically terminate script when MSBuild fails.
    Memoize results of Initialize* functions.
    Move build customization hooks to build.ps1.
    Make binary log off by default since it slows down build. It's on in CI build.
    Fixes to quiet restore workaround.
    Add set -u to bash script.
    Disable .NET Core telemetry on CI.
  • Loading branch information
tmat committed Dec 10, 2018
1 parent 7e7260b commit ca315f2
Show file tree
Hide file tree
Showing 16 changed files with 579 additions and 335 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Expand Up @@ -7,6 +7,12 @@ indent_style = space

[*.{sh}]
end_of_line = lf
indent_size = 2
tab_width = 2

[*.{ps1}]
indent_size = 2
tab_width = 2

[*.{cs}]
indent_size = 4
Expand Down
1 change: 0 additions & 1 deletion Build.cmd
@@ -1,3 +1,2 @@
@echo off
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore -build %*"
exit /b %ErrorLevel%
2 changes: 0 additions & 2 deletions Directory.Build.props
Expand Up @@ -15,9 +15,7 @@
Tools and packages produced by this repository support infrastructure and are not shipping on NuGet or via any other official channel.
-->
<IsShipping>false</IsShipping>
</PropertyGroup>

<PropertyGroup>
<!--
'NetFxTfm' is the standard desktop Target Framework Moniker which this repo's packages are targeting
ie. Place 'NetFxTfm' in the 'TargetFramework' property of a csproj like <TargetFrameworks>$(NetFxTfm);netcoreapp2.0</TargetFrameworks>
Expand Down
3 changes: 1 addition & 2 deletions Restore.cmd
@@ -1,3 +1,2 @@
@echo off
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore %*"
exit /b %ErrorLevel%
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore %*"
3 changes: 1 addition & 2 deletions Test.cmd
@@ -1,3 +1,2 @@
@echo off
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -test %*"
exit /b %ErrorLevel%
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -test %*"
8 changes: 1 addition & 7 deletions eng/Versions.props
Expand Up @@ -49,14 +49,8 @@
<MicrosoftDotNetBuildTasksFeedVersion>2.2.0-beta.18607.6</MicrosoftDotNetBuildTasksFeedVersion>
<MicrosoftDotNetMaestroTasksVersion>1.0.0-beta.18607.6</MicrosoftDotNetMaestroTasksVersion>
<MicrosoftDotNetSignToolVersion>1.0.0-beta.18607.6</MicrosoftDotNetSignToolVersion>
<!-- 3rd Part Packages Public Keys -->
<DynamicProxyGenAsm2Key>0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7</DynamicProxyGenAsm2Key>
</PropertyGroup>
<PropertyGroup>
<MicrosoftAzureDocumentDBVersion>1.22.0</MicrosoftAzureDocumentDBVersion>
<MicrosoftAzureCosmosDBTableVersion>1.1.2</MicrosoftAzureCosmosDBTableVersion>
</PropertyGroup>
<PropertyGroup>
<MicrosoftAspNetCoreAllVersion>2.0.0</MicrosoftAspNetCoreAllVersion>
<MicrosoftDotNetGitHubIssueLabelerAssetsVersion>1.2.0</MicrosoftDotNetGitHubIssueLabelerAssetsVersion>
<MicrosoftMLVersion>0.4.0</MicrosoftMLVersion>
Expand All @@ -69,7 +63,7 @@
$(RestoreSources);
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
https://dotnet.myget.org/F/symreader-converter/api/v3/index.json;
https:%2F%2Fdotnet.myget.org/F/symreader/api/v3/index.json
https://dotnet.myget.org/F/symreader/api/v3/index.json
</RestoreSources>
</PropertyGroup>
</Project>
78 changes: 52 additions & 26 deletions eng/common/build.ps1
@@ -1,15 +1,15 @@
[CmdletBinding(PositionalBinding=$false)]
Param(
[string] $configuration = "Debug",
[string][Alias('c')]$configuration = "Debug",
[string] $projects = "",
[string] $verbosity = "minimal",
[string][Alias('v')]$verbosity = "minimal",
[string] $msbuildEngine = $null,
[bool] $warnaserror = $true,
[bool] $nodereuse = $true,
[bool] $warnAsError = $true,
[bool] $nodeReuse = $true,
[switch] $execute,
[switch] $restore,
[switch][Alias('r')]$restore,
[switch] $deployDeps,
[switch] $build,
[switch][Alias('b')]$build,
[switch] $rebuild,
[switch] $deploy,
[switch] $test,
Expand All @@ -19,6 +19,7 @@ Param(
[switch] $pack,
[switch] $publish,
[switch] $publishBuildAssets,
[switch][Alias('bl')]$binaryLog,
[switch] $ci,
[switch] $prepareMachine,
[switch] $help,
Expand All @@ -29,14 +30,15 @@ Param(

function Print-Usage() {
Write-Host "Common settings:"
Write-Host " -configuration <value> Build configuration Debug, Release"
Write-Host " -verbosity <value> Msbuild verbosity (q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic])"
Write-Host " -configuration <value> Build configuration: 'Debug' or 'Release' (short: -c)"
Write-Host " -verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)"
Write-Host " -binaryLog Output binary log (short: -bl)"
Write-Host " -help Print help and exit"
Write-Host ""

Write-Host "Actions:"
Write-Host " -restore Restore dependencies"
Write-Host " -build Build solution"
Write-Host " -restore Restore dependencies (short: -r)"
Write-Host " -build Build solution (short: -b)"
Write-Host " -rebuild Rebuild solution"
Write-Host " -deploy Deploy built VSIXes"
Write-Host " -deployDeps Deploy dependencies (e.g. VSIXes for integration tests)"
Expand All @@ -46,7 +48,7 @@ function Print-Usage() {
Write-Host " -performanceTest Run all performance tests in the solution"
Write-Host " -sign Sign build outputs"
Write-Host " -publish Publish artifacts (e.g. symbols)"
Write-Host " -publishBuildAssets Push assets to BAR"
Write-Host " -publishBuildAssets Push assets to BAR"
Write-Host ""

Write-Host "Advanced settings:"
Expand All @@ -59,22 +61,26 @@ function Print-Usage() {
Write-Host "The above arguments can be shortened as much as to be unambiguous (e.g. -co for configuration, -t for test, etc.)."
}

if ($help -or (($properties -ne $null) -and ($properties.Contains("/help") -or $properties.Contains("/?")))) {
Print-Usage
exit 0
}

try {
if ($projects -eq "") {
$projects = Join-Path $RepoRoot "*.sln"
function InitializeCustomToolset {
if (-not $restore) {
return
}

InitializeTools
$script = Join-Path $EngRoot "restore-toolset.ps1"

$BuildLog = Join-Path $LogDir "Build.binlog"
if (Test-Path $script) {
. $script
}
}

function Build {
$toolsetBuildProj = InitializeToolset
InitializeCustomToolset
$bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "Build.binlog") } else { "" }

MSBuild $ToolsetBuildProj `
/bl:$BuildLog `
MSBuild $toolsetBuildProj `
$bl `
/p:Configuration=$configuration `
/p:Projects=$projects `
/p:RepoRoot=$RepoRoot `
Expand All @@ -92,17 +98,37 @@ try {
/p:Execute=$execute `
/p:ContinuousIntegrationBuild=$ci `
@properties
}

try {
if ($help -or (($properties -ne $null) -and ($properties.Contains("/help") -or $properties.Contains("/?")))) {
Print-Usage
exit 0
}

if ($lastExitCode -ne 0) {
Write-Host "Build Failed (exit code '$lastExitCode'). See log: $BuildLog" -ForegroundColor Red
ExitWithExitCode $lastExitCode
if ($projects -eq "") {
$projects = Join-Path $RepoRoot "*.sln"
}

ExitWithExitCode $lastExitCode
if ($ci) {
$binaryLog = $true
$nodeReuse = $false
}

# Import custom tools configuration, if present in the repo.
# Note: Import in global scope so that the script set top-level variables without qualification.
$configureToolsetScript = Join-Path $EngRoot "configure-toolset.ps1"
if (Test-Path $configureToolsetScript) {
. $configureToolsetScript
}

Build
}
catch {
Write-Host $_
Write-Host $_.Exception
Write-Host $_.ScriptStackTrace
ExitWithExitCode 1
}

ExitWithExitCode 0

0 comments on commit ca315f2

Please sign in to comment.