Browse Source

CSHARP-1707: Modify build scripts to also build and test against .NET Core.

pull/252/head
rstam 9 years ago
parent
commit
25eb3b195b
  1. 1
      .gitignore
  2. 1
      build.cmd
  3. 122
      build/build.fsx

1
.gitignore

@ -59,5 +59,6 @@ src/packages
artifacts artifacts
packages packages
Tools/FAKE Tools/FAKE
Tools/FAKE.Dotnet
Tools/xunit.runner.console Tools/xunit.runner.console

1
build.cmd

@ -1,4 +1,5 @@
@echo off @echo off
Tools\NuGet\NuGet.exe install FAKE -OutputDirectory Tools -ExcludeVersion Tools\NuGet\NuGet.exe install FAKE -OutputDirectory Tools -ExcludeVersion
Tools\NuGet\NuGet.exe install FAKE.Dotnet -OutputDirectory Tools -ExcludeVersion
Tools\NuGet\NuGet.exe install xunit.runner.console -OutputDirectory Tools -ExcludeVersion Tools\NuGet\NuGet.exe install xunit.runner.console -OutputDirectory Tools -ExcludeVersion
Tools\FAKE\tools\Fake.exe build\build.fsx %* Tools\FAKE\tools\Fake.exe build\build.fsx %*

122
build/build.fsx

@ -1,7 +1,10 @@
#r @"../Tools/FAKE/tools/FakeLib.dll" #r @"../Tools/FAKE/tools/FakeLib.dll"
#r @"../Tools/FAKE.Dotnet/tools/Fake.Dotnet.dll"
open System open System
open Fake open Fake
open Fake.AssemblyInfoFile open Fake.AssemblyInfoFile
open Fake.Dotnet
open Fake.Testing.XUnit2 open Fake.Testing.XUnit2
let config = getBuildParamOrDefault "config" "Release" let config = getBuildParamOrDefault "config" "Release"
@ -31,11 +34,13 @@ let buildDir = baseDir @@ "build"
let landingDocsDir = baseDir @@ "docs" @@ "landing" let landingDocsDir = baseDir @@ "docs" @@ "landing"
let refDocsDir = baseDir @@ "docs" @@ "reference" let refDocsDir = baseDir @@ "docs" @@ "reference"
let srcDir = baseDir @@ "src" let srcDir = baseDir @@ "src"
let testsDir = baseDir @@ "tests"
let toolsDir = baseDir @@ "tools" let toolsDir = baseDir @@ "tools"
let artifactsDir = baseDir @@ "artifacts" let artifactsDir = baseDir @@ "artifacts"
let binDir = artifactsDir @@ "bin" let binDir = artifactsDir @@ "bin"
let binDir45 = binDir @@ "net45"
let binDirNet45 = binDir @@ "net45"
let binDirNetStandard16 = binDir @@ "netstandard16"
let testResultsDir = artifactsDir @@ "test_results" let testResultsDir = artifactsDir @@ "test_results"
let tempDir = artifactsDir @@ "tmp" let tempDir = artifactsDir @@ "tmp"
@ -46,9 +51,33 @@ let slnFile =
let asmFile = srcDir @@ "MongoDB.Shared" @@ "GlobalAssemblyInfo.cs" let asmFile = srcDir @@ "MongoDB.Shared" @@ "GlobalAssemblyInfo.cs"
let apiDocsFile = baseDir @@ "Docs" @@ "Api" @@ "CSharpDriverDocs.shfbproj" let apiDocsFile = baseDir @@ "Docs" @@ "Api" @@ "CSharpDriverDocs.shfbproj"
let installerFile = baseDir @@ "Installer" @@ "CSharpDriverInstaller.wixproj"
let versionFile = artifactsDir @@ "version.txt" let versionFile = artifactsDir @@ "version.txt"
let dotNetSrcProjects = [
srcDir @@ "MongoDB.Bson.Dotnet" @@ "project.json"
srcDir @@ "MongoDB.Driver.Core.Dotnet" @@ "project.json"
srcDir @@ "MongoDB.Driver.Dotnet" @@ "project.json"
srcDir @@ "MongoDB.Driver.Legacy.Dotnet" @@ "project.json"
srcDir @@ "MongoDB.Driver.GridFS.Dotnet" @@ "project.json"
]
let dotNetTestHelpersProjects = [
testsDir @@ "MongoDB.Bson.TestHelpers.Dotnet" @@ "project.json"
testsDir @@ "MongoDB.Driver.Core.TestHelpers.Dotnet" @@ "project.json"
testsDir @@ "MongoDB.Driver.TestHelpers.Dotnet" @@ "project.json"
testsDir @@ "MongoDB.Driver.Legacy.TestHelpers.Dotnet" @@ "project.json"
]
let dotNetTestProjects = [
testsDir @@ "MongoDB.Bson.Tests.Dotnet" @@ "project.json"
testsDir @@ "MongoDB.Driver.Core.Tests.Dotnet" @@ "project.json"
testsDir @@ "MongoDB.Driver.Tests.Dotnet" @@ "project.json"
testsDir @@ "MongoDB.Driver.Legacy.Tests.Dotnet" @@ "project.json"
testsDir @@ "MongoDB.Driver.GridFS.Tests.Dotnet" @@ "project.json"
]
let dotNetProjects = List.concat [ dotNetSrcProjects; dotNetTestHelpersProjects; dotNetTestProjects ]
type NuspecFile = { File : string; Dependencies : string list; Symbols : bool; } type NuspecFile = { File : string; Dependencies : string list; Symbols : bool; }
let nuspecFiles = let nuspecFiles =
[ { File = buildDir @@ "MongoDB.Bson.nuspec"; Dependencies = []; Symbols = true; } [ { File = buildDir @@ "MongoDB.Bson.nuspec"; Dependencies = []; Symbols = true; }
@ -67,7 +96,7 @@ let apiDocsArtifactZipFile = artifactsDir @@ "ApiDocs-" + semVersion + "-html.zi
let refDocsArtifactZipFile = artifactsDir @@ "RefDocs-" + semVersion + "-html.zip" let refDocsArtifactZipFile = artifactsDir @@ "RefDocs-" + semVersion + "-html.zip"
let zipArtifactFile = artifactsDir @@ "CSharpDriver-" + semVersion + ".zip" let zipArtifactFile = artifactsDir @@ "CSharpDriver-" + semVersion + ".zip"
MSBuildDefaults <- { MSBuildDefaults with Verbosity = Some(Minimal) }
MSBuildDefaults <- { MSBuildDefaults with Verbosity = Some(MSBuildVerbosity.Minimal) }
monoArguments <- "--runtime=v4.0.30319" monoArguments <- "--runtime=v4.0.30319"
@ -103,7 +132,7 @@ Target "AssemblyInfo" (fun _ ->
AssemblyMetadata = ["githash", githash]}) AssemblyMetadata = ["githash", githash]})
) )
Target "Build" (fun _ ->
Target "BuildNet45" (fun _ ->
!! "./**/packages.config" !! "./**/packages.config"
|> Seq.iter (RestorePackage (fun x -> { x with OutputPath = baseDir @@ "packages" })) |> Seq.iter (RestorePackage (fun x -> { x with OutputPath = baseDir @@ "packages" }))
@ -115,17 +144,31 @@ Target "Build" (fun _ ->
properties <- properties @ ["DefineConstants", "MONO"] properties <- properties @ ["DefineConstants", "MONO"]
[slnFile] [slnFile]
|> MSBuild binDir45 "Build" properties
|> MSBuild binDirNet45 "Build" properties
|> Log "Build: " |> Log "Build: "
) )
Target "Test" (fun _ ->
if not <| directoryExists binDir45 then new Exception(sprintf "Directory %s does not exist." binDir45) |> raise
Target "InstallDotnet" (fun _ ->
DotnetCliInstall Preview2ToolingOptions
)
Target "BuildNetStandard16" (fun _ ->
for project in dotNetProjects do
DotnetRestore id project
DotnetCompile (fun c ->
{ c with
Configuration = BuildConfiguration.Release
})
project
)
Target "TestNet45" (fun _ ->
if not <| directoryExists binDirNet45 then new Exception(sprintf "Directory %s does not exist." binDirNet45) |> raise
ensureDirectory testResultsDir ensureDirectory testResultsDir
let mutable testsDir = !! (binDir45 @@ "*Tests*.dll")
let mutable testDlls = !! (binDirNet45 @@ "*Tests.dll")
if isMono then if isMono then
testsDir <- testsDir -- (binDir45 @@ "*VB.Tests*.dll")
testDlls <- testDlls -- (binDirNet45 @@ "*VB.Tests.dll")
let resultsOutputPath = testResultsDir @@ (getBuildParamOrDefault "testResults" "test-results.xml") let resultsOutputPath = testResultsDir @@ (getBuildParamOrDefault "testResults" "test-results.xml")
let includeTraits = let includeTraits =
@ -133,7 +176,7 @@ Target "Test" (fun _ ->
| "" -> [] | "" -> []
| category -> [("Category", category)] | category -> [("Category", category)]
testsDir
testDlls
|> xUnit2 (fun p -> |> xUnit2 (fun p ->
{ p with { p with
ErrorLevel = TestRunnerErrorLevel.Error ErrorLevel = TestRunnerErrorLevel.Error
@ -144,6 +187,13 @@ Target "Test" (fun _ ->
}) })
) )
Target "TestNetStandard16" (fun _ ->
for project in dotNetTestProjects do
let args = sprintf "test %s" project
let result = Dotnet DotnetOptions.Default args
if not result.OK then failwithf "dotnet test failed with code %i" result.ExitCode
)
Target "RefDocs" (fun _ -> Target "RefDocs" (fun _ ->
DeleteFile refDocsArtifactZipFile DeleteFile refDocsArtifactZipFile
ensureDirectory tempDir ensureDirectory tempDir
@ -188,7 +238,7 @@ Target "ApiDocs" (fun _ ->
"HelpFileVersion", version] "HelpFileVersion", version]
[apiDocsFile] [apiDocsFile]
|> MSBuild binDir45 "" properties
|> MSBuild binDirNet45 "" properties
|> Log "Docs: " |> Log "Docs: "
Rename apiDocsArtifactFile (tempDir @@ "CSharpDriverDocs.chm") Rename apiDocsArtifactFile (tempDir @@ "CSharpDriverDocs.chm")
@ -208,21 +258,21 @@ Target "Zip" (fun _ ->
checkFileExists releaseNotesFile checkFileExists releaseNotesFile
let files = let files =
[ binDir45 @@ "MongoDB.Bson.dll"
binDir45 @@ "MongoDB.Bson.pdb"
binDir45 @@ "MongoDB.Bson.xml"
binDir45 @@ "MongoDB.Driver.Core.dll"
binDir45 @@ "MongoDB.Driver.Core.pdb"
binDir45 @@ "MongoDB.Driver.Core.xml"
binDir45 @@ "MongoDB.Driver.dll"
binDir45 @@ "MongoDB.Driver.pdb"
binDir45 @@ "MongoDB.Driver.xml"
binDir45 @@ "MongoDB.Driver.GridFS.dll"
binDir45 @@ "MongoDB.Driver.GridFS.pdb"
binDir45 @@ "MongoDB.Driver.GridFS.xml"
binDir45 @@ "MongoDB.Driver.Legacy.dll"
binDir45 @@ "MongoDB.Driver.Legacy.pdb"
binDir45 @@ "MongoDB.Driver.Legacy.xml"
[ binDirNet45 @@ "MongoDB.Bson.dll"
binDirNet45 @@ "MongoDB.Bson.pdb"
binDirNet45 @@ "MongoDB.Bson.xml"
binDirNet45 @@ "MongoDB.Driver.Core.dll"
binDirNet45 @@ "MongoDB.Driver.Core.pdb"
binDirNet45 @@ "MongoDB.Driver.Core.xml"
binDirNet45 @@ "MongoDB.Driver.dll"
binDirNet45 @@ "MongoDB.Driver.pdb"
binDirNet45 @@ "MongoDB.Driver.xml"
binDirNet45 @@ "MongoDB.Driver.GridFS.dll"
binDirNet45 @@ "MongoDB.Driver.GridFS.pdb"
binDirNet45 @@ "MongoDB.Driver.GridFS.xml"
binDirNet45 @@ "MongoDB.Driver.Legacy.dll"
binDirNet45 @@ "MongoDB.Driver.Legacy.pdb"
binDirNet45 @@ "MongoDB.Driver.Legacy.xml"
licenseFile licenseFile
releaseNotesFile releaseNotesFile
apiDocsArtifactFile ] apiDocsArtifactFile ]
@ -283,11 +333,31 @@ Target "NoOp" DoNothing
Target "Docs" DoNothing Target "Docs" DoNothing
Target "Package" DoNothing Target "Package" DoNothing
Target "Publish" DoNothing Target "Publish" DoNothing
Target "Build" DoNothing
Target "Test" DoNothing
"Clean" "Clean"
==> "AssemblyInfo" ==> "AssemblyInfo"
"AssemblyInfo"
==> "BuildNet45"
"AssemblyInfo"
==> "InstallDotnet"
==> "BuildNetStandard16"
"BuildNet45"
==> "Build" ==> "Build"
"BuildNetStandard16"
==> "Build"
"TestNet45"
==> "Test"
"TestNetStandard16"
==> "Test"
"RefDocs" "RefDocs"
==> "ApiDocs" ==> "ApiDocs"
==> "Docs" ==> "Docs"

Loading…
Cancel
Save