Skip to content

Commit 9b439f2

Browse files
authored
Use ServerCommon build scripts for build, test, and signing (#34)
* Move to ServerCommon build scripts
1 parent 02f761f commit 9b439f2

14 files changed

Lines changed: 196 additions & 232 deletions

File tree

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,12 @@ DebugConstants.cs
205205
*.userprefs
206206
src/VsExtension/source.extension.vsixmanifest
207207
!packages/Microsoft.Web.Xdt.1.0.0-alpha/
208-
*.cache.bin
208+
*.cache.bin
209+
AssemblyInfo.g.cs
210+
tools
211+
.nuget/CredentialProvider.VSS.exe
212+
.nuget/CredentialProviderBundle.zip
213+
.nuget/EULA_Microsoft Visual Studio Team Services Credential Provider.docx
214+
.nuget/NuGet.exe
215+
.nuget/ThirdPartyNotices.txt
216+
Results.*.xml

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.nuget/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="xunit.runner.console" version="2.1.0" />
4+
</packages>

Enable-Signing.ps1

Lines changed: 0 additions & 112 deletions
This file was deleted.

Sign-Packages.ps1

Lines changed: 0 additions & 42 deletions
This file was deleted.

build.cmd

Lines changed: 0 additions & 70 deletions
This file was deleted.

build.ps1

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
[CmdletBinding(DefaultParameterSetName='RegularBuild')]
2+
param (
3+
[ValidateSet("debug", "release")]
4+
[string]$Configuration = 'debug',
5+
[int]$BuildNumber,
6+
[switch]$SkipRestore,
7+
[switch]$CleanCache,
8+
[string]$SimpleVersion = '1.0.0',
9+
[string]$SemanticVersion = '1.0.0-zlocal',
10+
[string]$Branch,
11+
[string]$CommitSHA,
12+
[string]$BuildBranch = '1c479a7381ebbc0fe1fded765de70d513b8bd68e'
13+
)
14+
15+
# 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
16+
trap {
17+
Write-Host "BUILD FAILED: $_" -ForegroundColor Red
18+
Write-Host "ERROR DETAILS:" -ForegroundColor Red
19+
Write-Host $_.Exception -ForegroundColor Red
20+
Write-Host ("`r`n" * 3)
21+
exit 1
22+
}
23+
24+
if (-not (Test-Path "$PSScriptRoot/build")) {
25+
New-Item -Path "$PSScriptRoot/build" -ItemType "directory"
26+
}
27+
wget -UseBasicParsing -Uri "https://raw.githubusercontent.com/NuGet/ServerCommon/$BuildBranch/build/init.ps1" -OutFile "$PSScriptRoot/build/init.ps1"
28+
. "$PSScriptRoot/build/init.ps1" -BuildBranch "$BuildBranch"
29+
30+
Write-Host ("`r`n" * 3)
31+
Trace-Log ('=' * 60)
32+
33+
$startTime = [DateTime]::UtcNow
34+
if (-not $BuildNumber) {
35+
$BuildNumber = Get-BuildNumber
36+
}
37+
Trace-Log "Build #$BuildNumber started at $startTime"
38+
39+
$BuildErrors = @()
40+
41+
Invoke-BuildStep 'Getting private build tools' { Install-PrivateBuildTools } `
42+
-ev +BuildErrors
43+
44+
Invoke-BuildStep 'Installing NuGet.exe' { Install-NuGet } `
45+
-ev +BuildErrors
46+
47+
Invoke-BuildStep 'Clearing package cache' { Clear-PackageCache } `
48+
-skip:(-not $CleanCache) `
49+
-ev +BuildErrors
50+
51+
Invoke-BuildStep 'Clearing artifacts' { Clear-Artifacts } `
52+
-ev +BuildErrors
53+
54+
Invoke-BuildStep 'Restoring solution packages' { `
55+
Install-SolutionPackages -path (Join-Path $PSScriptRoot ".nuget\packages.config") -output (Join-Path $PSScriptRoot "packages") } `
56+
-skip:$SkipRestore `
57+
-ev +BuildErrors
58+
59+
Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' {
60+
$Paths = @(Join-Path $PSScriptRoot "src\NuGet.Server\Properties\AssemblyInfo.g.cs")
61+
62+
Foreach ($Path in $Paths) {
63+
Set-VersionInfo -Path $Path -Version $SimpleVersion -Branch $Branch -Commit $CommitSHA
64+
}
65+
} `
66+
-ev +BuildErrors
67+
68+
Invoke-BuildStep 'Building solution' {
69+
$SolutionPath = Join-Path $PSScriptRoot "NuGet.Server.sln"
70+
Build-Solution $Configuration $BuildNumber -MSBuildVersion "14" $SolutionPath -SkipRestore:$SkipRestore `
71+
} `
72+
-ev +BuildErrors
73+
74+
Invoke-BuildStep 'Creating artifacts' {
75+
New-Package (Join-Path $PSScriptRoot "src\NuGet.Server\NuGet.Server.nuspec") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch
76+
} `
77+
-ev +BuildErrors
78+
79+
Trace-Log ('-' * 60)
80+
81+
## Calculating Build time
82+
$endTime = [DateTime]::UtcNow
83+
Trace-Log "Build #$BuildNumber ended at $endTime"
84+
Trace-Log "Time elapsed $(Format-ElapsedTime ($endTime - $startTime))"
85+
86+
Trace-Log ('=' * 60)
87+
88+
if ($BuildErrors) {
89+
$ErrorLines = $BuildErrors | %{ ">>> $($_.Exception.Message)" }
90+
Error-Log "Builds completed with $($BuildErrors.Count) error(s):`r`n$($ErrorLines -join "`r`n")" -Fatal
91+
}
92+
93+
Write-Host ("`r`n" * 3)

buildandtest.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[CmdletBinding(DefaultParameterSetName='RegularBuild')]
2+
param (
3+
[ValidateSet("debug", "release")]
4+
[string]$Configuration = 'debug',
5+
[int]$BuildNumber,
6+
[switch]$SkipRestore,
7+
[switch]$CleanCache,
8+
[string]$SimpleVersion = '1.0.0',
9+
[string]$SemanticVersion = '1.0.0-zlocal',
10+
[string]$Branch,
11+
[string]$CommitSHA
12+
)
13+
14+
$ScriptPath = Split-Path $MyInvocation.InvocationName
15+
16+
& "$ScriptPath\build.ps1" -Configuration $Configuration -BuildNumber $BuildNumber -SkipRestore:$SkipRestore -CleanCache:$CleanCache -SimpleVersion "$SimpleVersion" -SemanticVersion "$SemanticVersion" -Branch "$Branch" -CommitSHA "$CommitSHA"
17+
& "$ScriptPath\test.ps1" -Configuration $Configuration -BuildNumber $BuildNumber

src/CommonAssemblyInfo.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@
1313

1414
[assembly: ComVisible(false)]
1515

16-
[assembly: AssemblyVersion("2.14.0.0")]
17-
[assembly: AssemblyFileVersion("2.14.0.0")]
18-
1916
[assembly: NeutralResourcesLanguage("en-US")]

src/NuGet.Server/NuGet.Server.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
</Compile>
120120
<Compile Include="Infrastructure\PackageUtility.cs" />
121121
<Compile Include="Properties\AssemblyInfo.cs" />
122+
<Compile Include="Properties\AssemblyInfo.*.cs" />
122123
<Compile Include="DataServices\QueryableExtensions.cs" />
123124
<Compile Include="DataServices\QueryTranslator.cs" />
124125
<Compile Include="DataServices\QueryTranslatorProvider.cs" />
@@ -163,6 +164,7 @@
163164
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
164165
</PropertyGroup>
165166
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
167+
<Import Project="..\..\build\sign.targets" Condition="Exists('..\..\build\sign.targets')" />
166168
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != '' " />
167169
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
168170
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

0 commit comments

Comments
 (0)