Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
joelverhagen committed Jan 27, 2017
2 parents d58a743 + 5352539 commit ce6c5d6
Show file tree
Hide file tree
Showing 27 changed files with 435 additions and 706 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ Packages.dgml
[Dd]ebug/
[Rr]elease/
x64/
#build/ # We use this folder for our Build Scripts
[Bb]in/
[Oo]bj/

# Files created and used by our build scripts
build/
tools/
.nuget/CredentialProviderBundle.zip
AssemblyInfo.g.cs

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
Expand Down
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PowerShell.exe -NoProfile -ExecutionPolicy ByPass ".\build.ps1 -Configuration 'Release' -Verbose"
PowerShell.exe -NoProfile -ExecutionPolicy ByPass ".\buildandtest.ps1 -Configuration 'Release' -Verbose"
106 changes: 46 additions & 60 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
param (
[ValidateSet("debug", "release")]
[string]$Configuration = 'debug',
[ValidateSet("Release","rtm", "rc", "beta", "beta2", "final", "xprivate", "zlocal")]
[ValidateSet("Release","rtm", "rc", "beta", "beta2", "final", "xprivate", "zlocal")]
[string]$ReleaseLabel = 'zlocal',
[int]$BuildNumber,
[switch]$SkipRestore,
[switch]$CleanCache,
[string]$SimpleVersion = '1.0.0',
[string]$SemanticVersion = '1.0.0-zlocal',
[string]$Branch,
[string]$CommitSHA
[string]$SimpleVersion = '1.0.0',
[string]$SemanticVersion = '1.0.0-zlocal',
[string]$Branch,
[string]$CommitSHA,
[string]$BuildBranch = 'da881231d9ae9c966d0c18824f09f0122008e765'
)

# For TeamCity - If any issue occurs, this script fail the build. - By default, TeamCity returns an exit code of 0 for all powershell scripts, even if they fail
Expand All @@ -22,33 +23,21 @@ trap {
exit 1
}

. "$PSScriptRoot\build\common.ps1"

Function Run-BinSkim {
[CmdletBinding()]
param()

Trace-Log 'Running BinSkim'

$BinSkimExe = (Join-Path $PSScriptRoot "packages\Microsoft.CodeAnalysis.BinSkim\tools\x64\BinSkim.exe")

& $BinSkimExe analyze --config default --verbose (Join-Path $PSScriptRoot "src\NuGetGallery\bin\NuGetGallery.dll")
& $BinSkimExe analyze --config default --verbose (Join-Path $PSScriptRoot "src\NuGet.Services.Search.Client\bin\$Configuration\NuGet.Services.Search.Client.dll")
& $BinSkimExe analyze --config default --verbose (Join-Path $PSScriptRoot "src\NuGetGallery.Core\bin\$Configuration\NuGetGallery.Core.dll")
if (-not (Test-Path "$PSScriptRoot/build")) {
New-Item -Path "$PSScriptRoot/build" -ItemType "directory"
}
wget -UseBasicParsing -Uri "https://raw.githubusercontent.com/NuGet/ServerCommon/$BuildBranch/build/init.ps1" -OutFile "$PSScriptRoot/build/init.ps1"
. "$PSScriptRoot/build/init.ps1" -Branch "$BuildBranch"

Function Run-Tests {
[CmdletBinding()]
param()

Trace-Log 'Running tests'

$xUnitExe = (Join-Path $PSScriptRoot "packages\xunit.runner.console\tools\xunit.console.exe")

& $xUnitExe (Join-Path $PSScriptRoot "tests\NuGetGallery.Core.Facts\bin\$Configuration\NuGetGallery.Core.Facts.dll")
& $xUnitExe (Join-Path $PSScriptRoot "tests\NuGetGallery.Facts\bin\$Configuration\NuGetGallery.Facts.dll")
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)

Expand All @@ -59,53 +48,50 @@ if (-not $BuildNumber) {
Trace-Log "Build #$BuildNumber started at $startTime"

$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 } `
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' { `
param($Path, $Version, $Branch, $Commit)
Set-VersionInfo -Path $Path -Version $Version -Branch $Branch -Commit $Commit `
} `
-args (Join-Path $PSScriptRoot "src\NuGetGallery\Properties\AssemblyInfo.cs"), $SimpleVersion, $Branch, $CommitSHA `
-ev +BuildErrors
param($Path, $Version, $Branch, $Commit)
Set-VersionInfo -Path $Path -Version $Version -Branch $Branch -Commit $Commit `
} `
-args (Join-Path $PSScriptRoot "src\NuGetGallery\Properties\AssemblyInfo.g.cs"), $SimpleVersion, $Branch, $CommitSHA `
-ev +BuildErrors
Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' { `
param($Path, $Version, $Branch, $Commit)
Set-VersionInfo -Path $Path -Version $Version -Branch $Branch -Commit $Commit `
} `
-args (Join-Path $PSScriptRoot "src\NuGetGallery.Core\Properties\AssemblyInfo.cs"), $SimpleVersion, $Branch, $CommitSHA `
-ev +BuildErrors
param($Path, $Version, $Branch, $Commit)
Set-VersionInfo -Path $Path -Version $Version -Branch $Branch -Commit $Commit `
} `
-args (Join-Path $PSScriptRoot "src\NuGetGallery.Core\Properties\AssemblyInfo.g.cs"), $SimpleVersion, $Branch, $CommitSHA `
-ev +BuildErrors
Invoke-BuildStep 'Building solution' {
param($Configuration, $BuildNumber, $SolutionPath, $SkipRestore)
Build-Solution $Configuration $BuildNumber -MSBuildVersion "14" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" `
} `
-args $Configuration, $BuildNumber, (Join-Path $PSScriptRoot "NuGetGallery.sln"), $SkipRestore `
param($Configuration, $BuildNumber, $SolutionPath, $SkipRestore)
Build-Solution $Configuration $BuildNumber -MSBuildVersion "14" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" `
} `
-args $Configuration, $BuildNumber, (Join-Path $PSScriptRoot "NuGetGallery.sln"), $SkipRestore `
-ev +BuildErrors

Invoke-BuildStep 'Running BinSkim' { Run-BinSkim } `
-ev +BuildErrors

Invoke-BuildStep 'Running tests' { Run-Tests } `
-ev +BuildErrors


Invoke-BuildStep 'Creating artifacts' {
New-Package (Join-Path $PSScriptRoot "src\NuGetGallery.Core\NuGetGallery.Core.csproj") -Configuration $Configuration -BuildNumber $BuildNumber -ReleaseLabel $ReleaseLabel -Version $SemanticVersion `
-ev +BuildErrors
}
New-Package (Join-Path $PSScriptRoot "src\NuGetGallery.Core\NuGetGallery.Core.csproj") -Configuration $Configuration -BuildNumber $BuildNumber -ReleaseLabel $ReleaseLabel -Version $SemanticVersion `
-ev +BuildErrors
}

Trace-Log ('-' * 60)

Expand All @@ -118,7 +104,7 @@ Trace-Log ('=' * 60)

if ($BuildErrors) {
$ErrorLines = $BuildErrors | %{ ">>> $($_.Exception.Message)" }
Error-Log "Build's completed with $($BuildErrors.Count) error(s):`r`n$($ErrorLines -join "`r`n")" -Fatal
Error-Log "Builds completed with $($BuildErrors.Count) error(s):`r`n$($ErrorLines -join "`r`n")" -Fatal
}

Write-Host ("`r`n" * 3)
Loading

0 comments on commit ce6c5d6

Please sign in to comment.