-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Scott Bommarito
committed
Mar 20, 2019
1 parent
a683a70
commit eece80e
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PowerShell.exe -NoProfile -ExecutionPolicy ByPass ".\build.ps1 -Configuration 'Release' -Verbose" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
[CmdletBinding(DefaultParameterSetName='RegularBuild')] | ||
param ( | ||
[ValidateSet("debug", "release")] | ||
[string]$Configuration = 'debug', | ||
[int]$BuildNumber, | ||
[switch]$SkipRestore, | ||
[switch]$CleanCache, | ||
[string]$SimpleVersion = '1.0.0', | ||
[string]$SemanticVersion = '1.0.0-zlocal', | ||
[string]$PackageSuffix, | ||
[string]$Branch, | ||
[string]$CommitSHA, | ||
[string]$BuildBranch = '8209830d5f760e344de359a3bcf684bf36e0a8d5' | ||
) | ||
|
||
Set-StrictMode -Version 1.0 | ||
|
||
# This script should fail the build if any issue occurs. | ||
trap { | ||
Write-Host "BUILD FAILED: $_" -ForegroundColor Red | ||
Write-Host "ERROR DETAILS:" -ForegroundColor Red | ||
Write-Host $_.Exception -ForegroundColor Red | ||
Write-Host ("`r`n" * 3) | ||
exit 1 | ||
} | ||
|
||
if (-not (Test-Path "$PSScriptRoot/build")) { | ||
New-Item -Path "$PSScriptRoot/build" -ItemType "directory" | ||
} | ||
|
||
# Enable TLS 1.2 since GitHub requires it. | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 | ||
|
||
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/NuGet/ServerCommon/$BuildBranch/build/init.ps1" -OutFile "$PSScriptRoot/build/init.ps1" | ||
. "$PSScriptRoot/build/init.ps1" -BuildBranch "$BuildBranch" | ||
|
||
Function Clean-Tests { | ||
[CmdletBinding()] | ||
param() | ||
|
||
Trace-Log 'Cleaning test results' | ||
|
||
Remove-Item (Join-Path $PSScriptRoot "Results.*.xml") | ||
} | ||
|
||
Write-Host ("`r`n" * 3) | ||
Trace-Log ('=' * 60) | ||
|
||
$startTime = [DateTime]::UtcNow | ||
if (-not $BuildNumber) { | ||
$BuildNumber = Get-BuildNumber | ||
} | ||
Trace-Log "Build #$BuildNumber started at $startTime" | ||
|
||
$BuildErrors = @() | ||
|
||
Invoke-BuildStep "Update NuGetGallery submodule" { | ||
Invoke-Git 'submodule', 'update', '--init', '--', 'src/NuGet.Status/NuGetGallery' | ||
} ` | ||
-skip:($SkipSubModules -or $Fast) ` | ||
-ev +BuildErrors | ||
|
||
Invoke-BuildStep 'Getting private build tools' { Install-PrivateBuildTools } ` | ||
-ev +BuildErrors | ||
|
||
Invoke-BuildStep 'Cleaning test results' { Clean-Tests } ` | ||
-ev +BuildErrors | ||
|
||
Invoke-BuildStep 'Installing NuGet.exe' { Install-NuGet } ` | ||
-ev +BuildErrors | ||
|
||
Invoke-BuildStep 'Clearing package cache' { Clear-PackageCache } ` | ||
-skip:(-not $CleanCache) ` | ||
-ev +BuildErrors | ||
|
||
Invoke-BuildStep 'Clearing artifacts' { Clear-Artifacts } ` | ||
-ev +BuildErrors | ||
|
||
Invoke-BuildStep 'Restoring solution packages' { ` | ||
Install-SolutionPackages -path (Join-Path $PSScriptRoot ".nuget\packages.config") -output (Join-Path $PSScriptRoot "packages") -excludeversion } ` | ||
-skip:$SkipRestore ` | ||
-ev +BuildErrors | ||
|
||
Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' { | ||
$Paths = ` | ||
(Join-Path $PSScriptRoot "src\NuGet.Status\Properties\AssemblyInfo.g.cs") | ||
|
||
Foreach ($Path in $Paths) { | ||
Set-VersionInfo -Path $Path -Version $SimpleVersion -Branch $Branch -Commit $CommitSHA | ||
} | ||
} ` | ||
-ev +BuildErrors | ||
|
||
Invoke-BuildStep 'Building solution' { | ||
$SolutionPath = Join-Path $PSScriptRoot "src\NuGet.Status.sln" | ||
Build-Solution $Configuration $BuildNumber -MSBuildVersion "15" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" ` | ||
} ` | ||
-ev +BuildErrors | ||
|
||
Trace-Log ('-' * 60) | ||
|
||
## Calculating Build time | ||
$endTime = [DateTime]::UtcNow | ||
Trace-Log "Build #$BuildNumber ended at $endTime" | ||
Trace-Log "Time elapsed $(Format-ElapsedTime ($endTime - $startTime))" | ||
|
||
Trace-Log ('=' * 60) | ||
|
||
if ($BuildErrors) { | ||
$ErrorLines = $BuildErrors | %{ ">>> $($_.Exception.Message)" } | ||
Error-Log "Builds completed with $($BuildErrors.Count) error(s):`r`n$($ErrorLines -join "`r`n")" -Fatal | ||
} | ||
|
||
Write-Host ("`r`n" * 3) |