Skip to content

Commit 3443a44

Browse files
authored
Merge pull request #204 from Arkatufus/update_cross_framework_test
Update the cross framework spec to include complex POCO object, Type serialization, and support for netcoreapp3.1 and net5.0
2 parents ada4198 + 4bc1c7a commit 3443a44

18 files changed

+228
-121
lines changed

build-system/azure-pipeline.template.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ jobs:
1616
clean: false # whether to fetch clean each time
1717
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
1818
persistCredentials: true
19+
- task: UseDotNet@2
20+
displayName: 'Use .NET 5 SDK 5.0.101'
21+
inputs:
22+
version: 5.0.101
23+
- task: UseDotNet@2
24+
displayName: 'Use .NET Core Runtime 3.1.10'
25+
inputs:
26+
packageType: runtime
27+
version: 3.1.10
1928
# Linux or macOS
2029
- task: Bash@3
2130
displayName: Linux / OSX Build

build.fsx

Lines changed: 124 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ open System.Text
88
open Fake
99
open Fake.DotNetCli
1010
open Fake.DocFxHelper
11+
open Fake.NuGet.Install
1112

1213
// Information about the project for Nuget and Assembly info files
1314
let product = "Hyperion"
@@ -18,36 +19,58 @@ let signingName = "Hyperion"
1819
let signingDescription = "A high performance polymorphic serializer for the .NET framework"
1920
let signingUrl = ""
2021

22+
// Directories
23+
let toolsDir = __SOURCE_DIRECTORY__ @@ "tools"
24+
let output = __SOURCE_DIRECTORY__ @@ "bin"
25+
let outputTests = __SOURCE_DIRECTORY__ @@ "TestResults"
26+
let outputPerfTests = __SOURCE_DIRECTORY__ @@ "PerfResults"
27+
let outputBinaries = output @@ "binaries"
28+
let outputBinariesNet461 = outputBinaries @@ "net461"
29+
let outputBinariesNetStandard = outputBinaries @@ "netstandard2.0"
30+
let outputBinariesNet = outputBinaries @@ "net5.0"
31+
let outputNuGet = output @@ "nuget"
2132

2233
// Read release notes and version
2334
let solutionFile = FindFirstMatchingFile "*.sln" __SOURCE_DIRECTORY__ // dynamically look up the solution
2435
let buildNumber = environVarOrDefault "BUILD_NUMBER" "0"
2536
let hasTeamCity = (not (buildNumber = "0")) // check if we have the TeamCity environment variable for build # set
2637
let preReleaseVersionSuffix = "beta" + (if (not (buildNumber = "0")) then (buildNumber) else DateTime.UtcNow.Ticks.ToString())
27-
let versionSuffix =
28-
match (getBuildParam "nugetprerelease") with
29-
| "dev" -> preReleaseVersionSuffix
30-
| _ -> ""
3138

3239
let releaseNotes =
33-
File.ReadLines "./RELEASE_NOTES.md"
40+
File.ReadLines (__SOURCE_DIRECTORY__ @@ "RELEASE_NOTES.md")
3441
|> ReleaseNotesHelper.parseReleaseNotes
3542

36-
// Directories
37-
let toolsDir = __SOURCE_DIRECTORY__ @@ "tools"
38-
let output = __SOURCE_DIRECTORY__ @@ "bin"
39-
let outputTests = __SOURCE_DIRECTORY__ @@ "TestResults"
40-
let outputPerfTests = __SOURCE_DIRECTORY__ @@ "PerfResults"
41-
let outputNuGet = output @@ "nuget"
43+
let versionFromReleaseNotes =
44+
match releaseNotes.SemVer.PreRelease with
45+
| Some r -> r.Origin
46+
| None -> ""
47+
48+
let versionSuffix =
49+
match (getBuildParam "nugetprerelease") with
50+
| "dev" -> preReleaseVersionSuffix
51+
| "" -> versionFromReleaseNotes
52+
| str -> str
53+
54+
// Configuration values for tests
55+
let testNetFrameworkVersion = "net461"
56+
let testNetCoreVersion = "netcoreapp3.1"
57+
let testNetVersion = "net5.0"
4258

4359
Target "Clean" (fun _ ->
4460
ActivateFinalTarget "KillCreatedProcesses"
4561

4662
CleanDir output
4763
CleanDir outputTests
4864
CleanDir outputPerfTests
65+
CleanDir outputBinaries
4966
CleanDir outputNuGet
67+
CleanDir outputBinariesNet461
68+
CleanDir outputBinariesNetStandard
69+
CleanDir outputBinariesNet
5070
CleanDir "docs/_site"
71+
72+
CleanDirs !! "./**/bin"
73+
CleanDirs !! "./**/obj"
5174
)
5275

5376
Target "AssemblyInfo" (fun _ ->
@@ -56,17 +79,20 @@ Target "AssemblyInfo" (fun _ ->
5679
)
5780

5881
Target "Build" (fun _ ->
82+
let additionalArgs = if versionSuffix.Length > 0 then [sprintf "/p:VersionSuffix=%s" versionSuffix] else []
5983
DotNetCli.Build
6084
(fun p ->
6185
{ p with
6286
Project = solutionFile
63-
Configuration = configuration }) // "Rebuild"
87+
Configuration = configuration
88+
AdditionalArgs = additionalArgs }) // "Rebuild"
6489
)
6590

6691

6792
//--------------------------------------------------------------------------------
6893
// Tests targets
6994
//--------------------------------------------------------------------------------
95+
7096
module internal ResultHandling =
7197
let (|OK|Failure|) = function
7298
| 0 -> OK
@@ -94,8 +120,32 @@ Target "RunTests" (fun _ ->
94120
let runSingleProject project =
95121
let arguments =
96122
match (hasTeamCity) with
97-
| true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --results-directory %s -- -parallel none -teamcity" (outputTests))
98-
| false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --results-directory %s -- -parallel none" (outputTests))
123+
| true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetFrameworkVersion outputTests)
124+
| false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetFrameworkVersion outputTests)
125+
126+
let result = ExecProcess(fun info ->
127+
info.FileName <- "dotnet"
128+
info.WorkingDirectory <- (Directory.GetParent project).FullName
129+
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)
130+
131+
ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result
132+
133+
CreateDir outputTests
134+
projects |> Seq.iter (log)
135+
projects |> Seq.iter (runSingleProject)
136+
)
137+
138+
Target "RunTestsNetCore" (fun _ ->
139+
let projects =
140+
match (isWindows) with
141+
| true -> !! "./src/**/*.Tests.csproj"
142+
| _ -> !! "./src/**/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here
143+
144+
let runSingleProject project =
145+
let arguments =
146+
match (hasTeamCity) with
147+
| true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetCoreVersion outputTests)
148+
| false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetCoreVersion outputTests)
99149

100150
let result = ExecProcess(fun info ->
101151
info.FileName <- "dotnet"
@@ -104,44 +154,64 @@ Target "RunTests" (fun _ ->
104154

105155
ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result
106156

157+
CreateDir outputTests
158+
projects |> Seq.iter (log)
159+
projects |> Seq.iter (runSingleProject)
160+
)
161+
162+
Target "RunTestsNet" (fun _ ->
163+
let projects =
164+
match (isWindows) with
165+
| true -> !! "./src/**/*.Tests.csproj"
166+
| _ -> !! "./src/**/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here
167+
168+
let runSingleProject project =
169+
let arguments =
170+
match (hasTeamCity) with
171+
| true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetVersion outputTests)
172+
| false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetVersion outputTests)
173+
174+
let result = ExecProcess(fun info ->
175+
info.FileName <- "dotnet"
176+
info.WorkingDirectory <- (Directory.GetParent project).FullName
177+
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)
178+
179+
ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result
180+
181+
CreateDir outputTests
107182
projects |> Seq.iter (log)
108183
projects |> Seq.iter (runSingleProject)
109184
)
110185

111186
Target "NBench" <| fun _ ->
112-
let nbenchTestPath = findToolInSubPath "NBench.Runner.exe" (toolsDir @@ "NBench.Runner*")
113-
printfn "Using NBench.Runner: %s" nbenchTestPath
114-
115-
let nbenchTestAssemblies = !! "./src/**/bin/**/*Tests.Performance.dll" // doesn't support .NET Core at the moment
116-
117-
let runNBench assembly =
118-
let includes = getBuildParam "include"
119-
let excludes = getBuildParam "exclude"
120-
let teamcityStr = (getBuildParam "teamcity")
121-
let enableTeamCity =
122-
match teamcityStr with
123-
| null -> false
124-
| "" -> false
125-
| _ -> bool.Parse teamcityStr
126-
127-
let args = StringBuilder()
128-
|> append assembly
129-
|> append (sprintf "output-directory=\"%s\"" outputPerfTests)
130-
|> append (sprintf "concurrent=\"%b\"" true)
131-
|> append (sprintf "trace=\"%b\"" true)
132-
|> append (sprintf "teamcity=\"%b\"" enableTeamCity)
133-
|> appendIfNotNullOrEmpty includes "include="
134-
|> appendIfNotNullOrEmpty excludes "include="
187+
ensureDirectory outputPerfTests
188+
let projects =
189+
match (isWindows) with
190+
| true -> !! "./src/**/*Tests.Performance.csproj"
191+
| _ -> !! "./src/**/*Tests.Performance.csproj" // if you need to filter specs for Linux vs. Windows, do it here
192+
193+
projects |> Seq.iter(fun project ->
194+
let args = new StringBuilder()
195+
|> append "run"
196+
|> append "--no-build"
197+
|> append "-c"
198+
|> append configuration
199+
|> append " -- "
200+
|> append "--output"
201+
|> append outputPerfTests
202+
|> append "--concurrent"
203+
|> append "true"
204+
|> append "--trace"
205+
|> append "true"
206+
|> append "--diagnostic"
135207
|> toText
136208

137-
let result = ExecProcess(fun info ->
138-
info.FileName <- nbenchTestPath
139-
info.WorkingDirectory <- (Path.GetDirectoryName (FullName nbenchTestPath))
140-
info.Arguments <- args) (System.TimeSpan.FromMinutes 45.0) (* Reasonably long-running task. *)
141-
142-
if result <> 0 then failwithf "NBench.Runner failed. %s %s" nbenchTestPath args
143-
144-
nbenchTestAssemblies |> Seq.iter runNBench
209+
let result = ExecProcess(fun info ->
210+
info.FileName <- "dotnet"
211+
info.WorkingDirectory <- (Directory.GetParent project).FullName
212+
info.Arguments <- args) (System.TimeSpan.FromMinutes 15.0) (* Reasonably long-running task. *)
213+
if result <> 0 then failwithf "NBench.Runner failed. %s %s" "dotnet" args
214+
)
145215

146216

147217
//--------------------------------------------------------------------------------
@@ -301,23 +371,30 @@ Target "Help" <| fun _ ->
301371
Target "BuildRelease" DoNothing
302372
Target "All" DoNothing
303373
Target "Nuget" DoNothing
374+
Target "RunTestsFull" DoNothing
375+
Target "RunTestsNetCoreFull" DoNothing
304376

305377
// build dependencies
306378
"Clean" ==> "AssemblyInfo" ==> "Build" ==> "BuildRelease"
307379

308380
// tests dependencies
309381
"Build" ==> "RunTests"
382+
"Build" ==> "RunTestsNetCore"
383+
"Build" ==> "RunTestsNet"
384+
"Build" ==> "NBench"
310385

311386
// nuget dependencies
312-
"Clean" ==> "Build" ==> "CreateNuget"
387+
"BuildRelease" ==> "CreateNuget"
313388
"CreateNuget" ==> "SignPackages" ==> "PublishNuget" ==> "Nuget"
314389

315390
// docs
316-
"Clean" ==> "BuildRelease" ==> "Docfx"
391+
"BuildRelease" ==> "Docfx"
317392

318393
// all
319394
"BuildRelease" ==> "All"
320395
"RunTests" ==> "All"
396+
"RunTestsNetCore" ==> "All"
397+
"RunTestsNet" ==> "All"
321398
"NBench" ==> "All"
322399
"Nuget" ==> "All"
323400

build.ps1

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ Param(
2929
[string[]]$ScriptArgs
3030
)
3131

32-
$FakeVersion = "4.61.2"
33-
$DotNetChannel = "LTS";
34-
$DotNetVersion = "3.0.100";
35-
$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1";
36-
$NugetVersion = "4.1.0";
32+
$FakeVersion = "4.63.2"
33+
$NugetVersion = "5.8.0";
3734
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/v$NugetVersion/nuget.exe"
38-
$ProtobufVersion = "3.2.0"
39-
$DocfxVersion = "2.40.5"
35+
$ProtobufVersion = "3.13.0"
36+
$DocfxVersion = "2.48.1"
4037

4138
# Make sure tools folder exists
4239
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
@@ -46,51 +43,6 @@ if (!(Test-Path $ToolPath)) {
4643
New-Item -Path $ToolPath -Type directory | out-null
4744
}
4845

49-
###########################################################################
50-
# INSTALL .NET CORE CLI
51-
###########################################################################
52-
53-
Function Remove-PathVariable([string]$VariableToRemove)
54-
{
55-
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
56-
if ($path -ne $null)
57-
{
58-
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
59-
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
60-
}
61-
62-
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
63-
if ($path -ne $null)
64-
{
65-
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
66-
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
67-
}
68-
}
69-
70-
# Get .NET Core CLI path if installed.
71-
$FoundDotNetCliVersion = $null;
72-
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
73-
$FoundDotNetCliVersion = dotnet --version;
74-
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
75-
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
76-
}
77-
78-
if($FoundDotNetCliVersion -ne $DotNetVersion) {
79-
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
80-
if (!(Test-Path $InstallPath)) {
81-
mkdir -Force $InstallPath | Out-Null;
82-
}
83-
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
84-
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath -Architecture x64;
85-
86-
Remove-PathVariable "$InstallPath"
87-
$env:PATH = "$InstallPath;$env:PATH"
88-
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
89-
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
90-
$env:DOTNET_ROOT=$InstallPath
91-
}
92-
93-
9446
###########################################################################
9547
# INSTALL NUGET
9648
###########################################################################

build.sh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,6 @@ if [ ! -d "$TOOLS_DIR" ]; then
4141
mkdir "$TOOLS_DIR"
4242
fi
4343

44-
###########################################################################
45-
# INSTALL .NET CORE CLI
46-
###########################################################################
47-
48-
echo "Installing .NET CLI..."
49-
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
50-
mkdir "$SCRIPT_DIR/.dotnet"
51-
fi
52-
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" $DOTNET_INSTALLER_URL
53-
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --channel $DOTNET_CHANNEL --install-dir .dotnet --no-path
54-
export PATH="$SCRIPT_DIR/.dotnet":$PATH
55-
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
56-
export DOTNET_CLI_TELEMETRY_OPTOUT=1
57-
chmod -R 0755 ".dotnet"
58-
"$SCRIPT_DIR/.dotnet/dotnet" --info
59-
60-
6144
###########################################################################
6245
# INSTALL NUGET
6346
###########################################################################

0 commit comments

Comments
 (0)