@@ -4,18 +4,16 @@ param (
44 [string ]$Configuration = ' debug' ,
55 [int ]$BuildNumber ,
66 [switch ]$SkipRestore ,
7- [switch ]$CleanCache ,
87 [string ]$GalleryAssemblyVersion = ' 4.4.5' ,
98 [string ]$GalleryPackageVersion = ' 4.4.5-zlocal' ,
109 [string ]$Branch ,
1110 [string ]$CommitSHA ,
12- [string ]$BuildBranchCommit = ' 00a01b766623fb5b714238c4e814e906a242e88e ' , # DevSkim: ignore DS173237. Not a secret/token. It is a commit hash.
11+ [string ]$BuildBranchCommit = ' 8ea7f23faa289682fd02284a14959ab2c67ad546 ' , # DevSkim: ignore DS173237. Not a secret/token. It is a commit hash.
1312 [string ]$VerifyMicrosoftPackageVersion = $null
1413)
1514
1615Set-StrictMode - Version 1.0
1716
18- # This script should fail the build if any issue occurs.
1917trap {
2018 Write-Host " BUILD FAILED: $_ " - ForegroundColor Red
2119 Write-Host " ERROR DETAILS:" - ForegroundColor Red
@@ -41,63 +39,46 @@ if (-not $BuildNumber) {
4139Trace-Log " Build #$BuildNumber started at $startTime "
4240
4341$BuildErrors = @ ()
42+ $GallerySolution = Join-Path $PSScriptRoot " NuGetGallery.sln"
43+ $GalleryProjects = Get-SolutionProjects $GallerySolution
4444
4545Invoke-BuildStep ' Getting private build tools' { Install-PrivateBuildTools } `
4646 - ev + BuildErrors
4747
48- Invoke-BuildStep ' Cleaning test results' { Clear-Tests } `
49- - ev + BuildErrors
50-
5148Invoke-BuildStep ' Installing NuGet.exe' { Install-NuGet } `
5249 - ev + BuildErrors
5350
54- Invoke-BuildStep ' Clearing package cache' { Clear-PackageCache } `
55- - skip:(-not $CleanCache ) `
56- - ev + BuildErrors
57-
5851Invoke-BuildStep ' Clearing artifacts' { Clear-Artifacts } `
5952 - ev + BuildErrors
6053
61- Invoke-BuildStep ' Restoring solution packages' { `
62- Install-SolutionPackages - path (Join-Path $PSScriptRoot " packages.config" ) - output (Join-Path $PSScriptRoot " packages" ) - excludeversion } `
54+ Invoke-BuildStep ' Restoring solution packages' {
55+ $SolutionPath = Join-Path $PSScriptRoot " packages.config"
56+ $PackagesDir = Join-Path $PSScriptRoot " packages"
57+ Install-SolutionPackages - path $SolutionPath - output $PackagesDir - ExcludeVersion
58+ } `
6359 - skip:$SkipRestore `
6460 - ev + BuildErrors
6561
66- Invoke-BuildStep ' Set version metadata in AssemblyInfo.cs' {
67- $GalleryAssemblyInfo =
68- " src\AccountDeleter\Properties\AssemblyInfo.g.cs" ,
69- " src\DatabaseMigrationTools\Properties\AssemblyInfo.g.cs" ,
70- " src\GalleryTools\Properties\AssemblyInfo.g.cs" ,
71- " src\GitHubVulnerabilities2Db\Properties\AssemblyInfo.g.cs" ,
72- " src\GitHubVulnerabilities2v3\Properties\AssemblyInfo.g.cs" ,
73- " src\NuGet.Services.DatabaseMigration\Properties\AssemblyInfo.g.cs" ,
74- " src\NuGet.Services.Entities\Properties\AssemblyInfo.g.cs" ,
75- " src\NuGetGallery.Core\Properties\AssemblyInfo.g.cs" ,
76- " src\NuGetGallery.Services\Properties\AssemblyInfo.g.cs" ,
77- " src\NuGetGallery\Properties\AssemblyInfo.g.cs" ,
78- " src\VerifyMicrosoftPackage\Properties\AssemblyInfo.g.cs"
79- $GalleryAssemblyInfo | ForEach-Object {
80- Set-VersionInfo (Join-Path $PSScriptRoot $_ ) - AssemblyVersion $GalleryAssemblyVersion - PackageVersion $GalleryPackageVersion - Branch $Branch - Commit $CommitSHA
62+ Invoke-BuildStep ' Setting gallery version metadata in AssemblyInfo.cs' {
63+ $GalleryProjects | Where-Object { ! $_.IsTest } | ForEach-Object {
64+ $Path = Join-Path $_.Directory " Properties\AssemblyInfo.g.cs"
65+ Set-VersionInfo $Path - AssemblyVersion $GalleryAssemblyVersion - PackageVersion $GalleryPackageVersion - Branch $Branch - Commit $CommitSHA
8166 }
8267 } `
8368 - ev + BuildErrors
8469
85- Invoke-BuildStep ' Removing .editorconfig file in NuGetGallery' { Remove-EditorconfigFile - Directory $PSScriptRoot } `
86- - ev + BuildErrors
87-
88- Invoke-BuildStep ' Building solution' {
89- $SolutionPath = Join-Path $PSScriptRoot " NuGetGallery.sln"
70+ Invoke-BuildStep ' Building gallery solution' {
9071 $MvcBuildViews = $Configuration -eq " Release"
91- Build-Solution - Configuration $Configuration - BuildNumber $BuildNumber - SolutionPath $SolutionPath - SkipRestore:$SkipRestore - MSBuildProperties " /p:MvcBuildViews=$MvcBuildViews " `
72+ Build-Solution - Configuration $Configuration - BuildNumber $BuildNumber - SolutionPath $GallerySolution - SkipRestore:$SkipRestore - MSBuildProperties " /p:MvcBuildViews=$MvcBuildViews " `
9273 } `
9374 - ev + BuildErrors
9475
9576Invoke-BuildStep ' Signing the binaries' {
96- Sign- Binaries - Configuration $Configuration - BuildNumber $BuildNumber `
77+ Sign- Binaries - Configuration $Configuration - BuildNumber $BuildNumber
9778 } `
9879 - ev + BuildErrors
9980
100- Invoke-BuildStep ' Creating artifacts' { `
81+ Invoke-BuildStep ' Creating gallery artifacts' { `
10182 $GalleryProjects =
10283 " src\NuGet.Services.DatabaseMigration\NuGet.Services.DatabaseMigration.csproj" ,
10384 " src\NuGet.Services.Entities\NuGet.Services.Entities.csproj" ,
@@ -126,7 +107,7 @@ Invoke-BuildStep 'Creating artifacts' { `
126107 - ev + BuildErrors
127108
128109Invoke-BuildStep ' Signing the packages' {
129- Sign- Packages - Configuration $Configuration - BuildNumber $BuildNumber `
110+ Sign- Packages - Configuration $Configuration - BuildNumber $BuildNumber
130111 } `
131112 - ev + BuildErrors
132113
0 commit comments