Skip to content

Commit d0b5fa9

Browse files
authored
Move test projects to SDK-based .csproj (#10087)
* Move tests to SDK-based .csproj * Use latest lang * Move functional test solution to root * Move functional test csproj to SDK-based * New build tools to fix signing * Pass in VSINSTALLDIR for functional test build * Remove <IsPackable> since xunit.core adds it via IsTestProject
1 parent 430967d commit d0b5fa9

48 files changed

Lines changed: 284 additions & 1792 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,14 @@ FodyWeavers.xsd
400400
#######################
401401
# Repository specific #
402402
#######################
403-
build/
404-
tools/
403+
.nuget/
404+
nuget.exe
405405
Results.*.xml
406406
AssemblyInfo.*.cs
407-
.nuget/.marker.v*
408-
nuget.exe
407+
408+
# common build tools
409+
build/
410+
tools/
409411

410412
# Functional test results
411413
tests/functionaltests.*.xml

.pipelines/NuGetGallery-CI.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ extends:
7575
scriptName: $(NuGetGalleryPath)\test.ps1
7676
arguments: -Configuration $(BuildConfiguration) -BuildNumber $(Build.BuildId)
7777
workingFolder: $(NuGetGalleryPath)
78-
- task: PublishTestResults@1
78+
- task: PublishTestResults@2
7979
name: PublishTestResults_3
8080
displayName: Publish Test Results Results.*.xml
8181
condition: succeededOrFailed()
8282
inputs:
83-
testRunner: XUnit
83+
testRunner: VSTest
8484
testResultsFiles: $(NuGetGalleryPath)\Results.*.xml
85+
failTaskOnFailedTests: true

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1212
<IncludeSymbols Condition="'$(IncludeSymbols)' == ''">true</IncludeSymbols>
1313
<SymbolPackageFormat Condition="'$(SymbolPackageFormat)' == ''">snupkg</SymbolPackageFormat>
14-
<LangVersion>9.0</LangVersion>
14+
<LangVersion>latest</LangVersion>
1515

1616
<!--
1717
Our builds generate a file containing the desired assembly version attributes.

Directory.Packages.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
55
<EnablePackageVersionOverride>true</EnablePackageVersionOverride>
6-
76
<NuGetClientPackageVersion>6.9.1</NuGetClientPackageVersion>
87
<ServerCommonPackageVersion>2.120.0</ServerCommonPackageVersion>
98
<NuGetJobsPackageVersion>4.3.0-agr-gal-stsdk-9768098</NuGetJobsPackageVersion>

NuGet.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<clear />
1313
<packageSource key="NuGet.org">
1414
<package pattern="Antlr" />
15-
<package pattern="Autofac" />
1615
<package pattern="Autofac.*" />
16+
<package pattern="Autofac" />
1717
<package pattern="Azure.*" />
1818
<package pattern="Castle.Core" />
1919
<package pattern="CommonMark.NET" />
@@ -24,8 +24,8 @@
2424
<package pattern="FluentLinkChecker" />
2525
<package pattern="Hyak.Common" />
2626
<package pattern="Knapcode.MiniZip" />
27-
<package pattern="Lucene.Net" />
2827
<package pattern="Lucene.Net.Contrib" />
28+
<package pattern="Lucene.Net" />
2929
<package pattern="Markdig.Signed" />
3030
<package pattern="MicroBuild.Core" />
3131
<package pattern="Microsoft.*" />
@@ -37,21 +37,21 @@
3737
<package pattern="Newtonsoft.Json" />
3838
<package pattern="NuGet.*" />
3939
<package pattern="Owin" />
40-
<package pattern="Polly" />
4140
<package pattern="Polly.Extensions.Http" />
41+
<package pattern="Polly" />
4242
<package pattern="RazorEngine" />
4343
<package pattern="RouteMagic" />
4444
<package pattern="Runtime.*" />
45-
<package pattern="Serilog" />
4645
<package pattern="Serilog.*" />
46+
<package pattern="Serilog" />
4747
<package pattern="SerilogTraceListener" />
4848
<package pattern="SharpZipLib" />
4949
<package pattern="System.*" />
5050
<package pattern="WebActivatorEx" />
5151
<package pattern="WebGrease" />
5252
<package pattern="WindowsAzure.*" />
53-
<package pattern="xunit" />
5453
<package pattern="xunit.*" />
54+
<package pattern="xunit" />
5555
</packageSource>
5656
<packageSource key="nuget-build">
5757
<package pattern="Microsoft.AspNet.WebApi.MessageHandlers.Compression.Strongname" />
Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27705.2000
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.11.35111.106
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{37E5C8A5-C7A6-400E-A0EA-6C2C6F9B160D}"
77
ProjectSection(SolutionItems) = preProject
88
Local.testsettings = Local.testsettings
99
EndProjectSection
1010
EndProject
11-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.FunctionalTests", "NuGetGallery.FunctionalTests\NuGetGallery.FunctionalTests.csproj", "{073797B8-8D6C-4A82-9788-C38848D4CC59}"
11+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.FunctionalTests", "tests\NuGetGallery.FunctionalTests\NuGetGallery.FunctionalTests.csproj", "{073797B8-8D6C-4A82-9788-C38848D4CC59}"
1212
EndProject
13-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.FunctionalTests.Core", "NuGetGallery.FunctionalTests.Core\NuGetGallery.FunctionalTests.Core.csproj", "{8496C7FE-8A93-4D2E-A9DC-5DE44017187C}"
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.FunctionalTests.Core", "tests\NuGetGallery.FunctionalTests.Core\NuGetGallery.FunctionalTests.Core.csproj", "{8496C7FE-8A93-4D2E-A9DC-5DE44017187C}"
1414
EndProject
15-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{15D542B4-3214-4B0A-A427-BC3071BFE84D}"
16-
ProjectSection(SolutionItems) = preProject
17-
.nuget\packages.config = .nuget\packages.config
18-
EndProjectSection
19-
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.P0", "NuGetGallery.WebUITests.P0\NuGetGallery.WebUITests.P0.csproj", "{B3D313C5-A076-424C-B812-4EDE2D9EE888}"
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.LoadTests", "tests\NuGetGallery.LoadTests\NuGetGallery.LoadTests.csproj", "{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}"
2116
EndProject
22-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.P1", "NuGetGallery.WebUITests.P1\NuGetGallery.WebUITests.P1.csproj", "{66ACA75F-EE4D-4D23-AEC5-E38C715CDC7E}"
17+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.P0", "tests\NuGetGallery.WebUITests.P0\NuGetGallery.WebUITests.P0.csproj", "{B3D313C5-A076-424C-B812-4EDE2D9EE888}"
2318
EndProject
24-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.P2", "NuGetGallery.WebUITests.P2\NuGetGallery.WebUITests.P2.csproj", "{30F7F8C9-46BC-4677-9D26-43395A2B6DF5}"
19+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.P1", "tests\NuGetGallery.WebUITests.P1\NuGetGallery.WebUITests.P1.csproj", "{66ACA75F-EE4D-4D23-AEC5-E38C715CDC7E}"
2520
EndProject
26-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.ReadOnlyMode", "NuGetGallery.WebUITests.ReadOnlyMode\NuGetGallery.WebUITests.ReadOnlyMode.csproj", "{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}"
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.P2", "tests\NuGetGallery.WebUITests.P2\NuGetGallery.WebUITests.P2.csproj", "{30F7F8C9-46BC-4677-9D26-43395A2B6DF5}"
2722
EndProject
28-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.LoadTests", "NuGetGallery.LoadTests\NuGetGallery.LoadTests.csproj", "{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}"
23+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.ReadOnlyMode", "tests\NuGetGallery.WebUITests.ReadOnlyMode\NuGetGallery.WebUITests.ReadOnlyMode.csproj", "{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}"
2924
EndProject
3025
Global
3126
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -41,6 +36,10 @@ Global
4136
{8496C7FE-8A93-4D2E-A9DC-5DE44017187C}.Debug|Any CPU.Build.0 = Debug|Any CPU
4237
{8496C7FE-8A93-4D2E-A9DC-5DE44017187C}.Release|Any CPU.ActiveCfg = Release|Any CPU
4338
{8496C7FE-8A93-4D2E-A9DC-5DE44017187C}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}.Release|Any CPU.Build.0 = Release|Any CPU
4443
{B3D313C5-A076-424C-B812-4EDE2D9EE888}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4544
{B3D313C5-A076-424C-B812-4EDE2D9EE888}.Debug|Any CPU.Build.0 = Debug|Any CPU
4645
{B3D313C5-A076-424C-B812-4EDE2D9EE888}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -57,10 +56,6 @@ Global
5756
{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}.Debug|Any CPU.Build.0 = Debug|Any CPU
5857
{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}.Release|Any CPU.ActiveCfg = Release|Any CPU
5958
{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}.Release|Any CPU.Build.0 = Release|Any CPU
60-
{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61-
{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
62-
{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
63-
{0A6B1A52-4D26-4946-9DDD-416D01A1ADBF}.Release|Any CPU.Build.0 = Release|Any CPU
6459
EndGlobalSection
6560
GlobalSection(SolutionProperties) = preSolution
6661
HideSolutionNode = FALSE

SdkProjects.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<SignPath Condition="'$(NuGetBuildPath)' != ''">$(NuGetBuildPath)</SignPath>
2020
<SignType Condition="'$(SignType)' == ''">none</SignType>
2121
</PropertyGroup>
22+
<Import Project="sign.thirdparty.props" />
2223
<Import Project="$(SignPath)\sign.targets" Condition="Exists('$(SignPath)\sign.targets')" />
2324
<Import Project="$(SignPath)\sign.microbuild.targets" Condition="Exists('$(SignPath)\sign.microbuild.targets')" />
2425
</Project>

build.ps1

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1615
Set-StrictMode -Version 1.0
1716

18-
# This script should fail the build if any issue occurs.
1917
trap {
2018
Write-Host "BUILD FAILED: $_" -ForegroundColor Red
2119
Write-Host "ERROR DETAILS:" -ForegroundColor Red
@@ -41,63 +39,46 @@ if (-not $BuildNumber) {
4139
Trace-Log "Build #$BuildNumber started at $startTime"
4240

4341
$BuildErrors = @()
42+
$GallerySolution = Join-Path $PSScriptRoot "NuGetGallery.sln"
43+
$GalleryProjects = Get-SolutionProjects $GallerySolution
4444

4545
Invoke-BuildStep 'Getting private build tools' { Install-PrivateBuildTools } `
4646
-ev +BuildErrors
4747

48-
Invoke-BuildStep 'Cleaning test results' { Clear-Tests } `
49-
-ev +BuildErrors
50-
5148
Invoke-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-
5851
Invoke-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

9576
Invoke-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

128109
Invoke-BuildStep 'Signing the packages' {
129-
Sign-Packages -Configuration $Configuration -BuildNumber $BuildNumber `
110+
Sign-Packages -Configuration $Configuration -BuildNumber $BuildNumber
130111
} `
131112
-ev +BuildErrors
132113

src/NuGetGallery.Services/NuGetGallery.Services.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
6161
<PackageReference Include="Microsoft.AspNet.Mvc" />
6262
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" />
63-
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />
63+
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />
6464
<PackageReference Include="Microsoft.Owin" />
6565
<PackageReference Include="Microsoft.Owin.Host.SystemWeb" />
6666
<PackageReference Include="Microsoft.Owin.Security" />

test.ps1

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,6 @@ trap {
1515

1616
. "$PSScriptRoot\build\common.ps1"
1717

18-
Function Invoke-Tests {
19-
[CmdletBinding()]
20-
param()
21-
22-
Trace-Log 'Running tests'
23-
24-
$xUnitExe = (Join-Path $PSScriptRoot "packages\xunit.runner.console\tools\net472\xunit.console.exe")
25-
26-
$GalleryTestAssemblies = `
27-
"tests\AccountDeleter.Facts\bin\$Configuration\net472\AccountDeleter.Facts.dll", `
28-
"tests\GitHubVulnerabilities2Db.Facts\bin\$Configuration\net472\GitHubVulnerabilities2Db.Facts.dll", `
29-
"tests\GitHubVulnerabilities2v3.Facts\bin\$Configuration\GitHubVulnerabilities2v3.Facts.dll", `
30-
"tests\NuGet.Services.DatabaseMigration.Facts\bin\$Configuration\net472\NuGet.Services.DatabaseMigration.Facts.dll", `
31-
"tests\NuGet.Services.Entities.Tests\bin\$Configuration\net472\NuGet.Services.Entities.Tests.dll", `
32-
"tests\NuGetGallery.Core.Facts\bin\$Configuration\NuGetGallery.Core.Facts.dll", `
33-
"tests\NuGetGallery.Facts\bin\$Configuration\NuGetGallery.Facts.dll", `
34-
"tests\VerifyMicrosoftPackage.Facts\bin\$Configuration\NuGet.VerifyMicrosoftPackage.Facts.dll"
35-
36-
$TestCount = 0
37-
38-
$GalleryTestAssemblies | ForEach-Object {
39-
$TestResultFile = Join-Path $PSScriptRoot "Results.$TestCount.xml"
40-
& $xUnitExe (Join-Path $PSScriptRoot $_) -xml $TestResultFile
41-
if (-not (Test-Path $TestResultFile)) {
42-
Write-Error "The test run failed to produce a result file";
43-
exit 1;
44-
}
45-
$TestCount++
46-
}
47-
48-
Write-Host "Ensuring the EntityFramework version can be discovered."
49-
. (Join-Path $PSScriptRoot "tools\Update-Databases.ps1") -MigrationTargets @("FakeMigrationTarget")
50-
}
51-
5218
Write-Host ("`r`n" * 3)
5319
Trace-Log ('=' * 60)
5420

@@ -58,10 +24,33 @@ if (-not $BuildNumber) {
5824
}
5925
Trace-Log "Build #$BuildNumber started at $startTime"
6026

61-
$BuildErrors = @()
62-
63-
Invoke-BuildStep 'Running tests' { Invoke-Tests } `
64-
-ev +BuildErrors
27+
$TestErrors = @()
28+
$GallerySolution = Join-Path $PSScriptRoot "NuGetGallery.sln"
29+
$GalleryProjects = Get-SolutionProjects $GallerySolution
30+
31+
Invoke-BuildStep 'Cleaning test results' { Clear-Tests } `
32+
-ev +TestErrors
33+
34+
Invoke-BuildStep 'Running gallery tests' {
35+
$GalleryTestProjects = $GalleryProjects | Where-Object { $_.IsTest }
36+
37+
$TestCount = 0
38+
39+
$GalleryTestProjects | ForEach-Object {
40+
$TestResultFile = Join-Path $PSScriptRoot "Results.Gallery.$TestCount.xml"
41+
Trace-Log "Testing $($_.Path)"
42+
dotnet test $_.Path --no-restore --no-build --configuration $Configuration "-l:trx;LogFileName=$TestResultFile"
43+
if (-not (Test-Path $TestResultFile)) {
44+
Write-Error "The test run failed to produce a result file";
45+
exit 1;
46+
}
47+
$TestCount++
48+
}
49+
50+
Write-Host "Ensuring the EntityFramework version can be discovered."
51+
. (Join-Path $PSScriptRoot "tools\Update-Databases.ps1") -MigrationTargets @("FakeMigrationTarget")
52+
} `
53+
-ev +TestErrors
6554

6655
Trace-Log ('-' * 60)
6756

@@ -72,9 +61,9 @@ Trace-Log "Time elapsed $(Format-ElapsedTime ($endTime - $startTime))"
7261

7362
Trace-Log ('=' * 60)
7463

75-
if ($BuildErrors) {
76-
$ErrorLines = $BuildErrors | ForEach-Object { ">>> $($_.Exception.Message)" }
77-
Error-Log "Tests completed with $($BuildErrors.Count) error(s):`r`n$($ErrorLines -join "`r`n")" -Fatal
64+
if ($TestErrors) {
65+
$ErrorLines = $TestErrors | ForEach-Object { ">>> $($_.Exception.Message)" }
66+
Error-Log "Tests completed with $($TestErrors.Count) error(s):`r`n$($ErrorLines -join "`r`n")" -Fatal
7867
}
7968

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

0 commit comments

Comments
 (0)