Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#106 xunit netcore #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 40 additions & 22 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Target "CopyBinaries" (fun _ ->
// Clean build results

Target "Clean" (fun _ ->
CleanDirs ["bin"; "temp"; "src/FsUnit.NUnit/bin/"]
CleanDirs ["bin"; "temp"; "src/FsUnit.NUnit/bin/"; "src/FsUnit.Xunit/bin/"; "src/FsUnit.MsTestUnit/bin/"]
)

Target "CleanDocs" (fun _ ->
Expand Down Expand Up @@ -331,34 +331,50 @@ Target "Release" (fun _ ->
Target "BuildPackage" DoNothing

// --------------------------------------------------------------------------------------
// Build netcore expecto library
// Build netcore libraries

Target "NUnitCore" (fun _ ->
let buildNetCoreLibrary testsDir testsProj =
// Build all and execute unit tests
let nunitTestsDir, nunitTestsProj = "tests/FsUnit.NUnit.Test", "FsUnit.NUnit.Test.netcoreapp.fsproj"
DotNetCli.Restore (fun c -> { c with WorkingDir = nunitTestsDir; Project = nunitTestsProj })
DotNetCli.Build (fun c -> { c with WorkingDir = nunitTestsDir; Project = nunitTestsProj })
DotNetCli.RunCommand (fun c -> { c with WorkingDir = nunitTestsDir })
(sprintf "run --project %s" nunitTestsProj)
DotNetCli.Restore (fun c -> { c with WorkingDir = testsDir; Project = testsProj })
DotNetCli.Build (fun c -> { c with WorkingDir = testsDir; Project = testsProj })
DotNetCli.Test (fun c -> { c with WorkingDir = testsDir; Project = testsProj })

Target "NUnitCore" (fun _ ->
buildNetCoreLibrary "tests/FsUnit.NUnit.Test" "FsUnit.NUnit.Test.netcoreapp.fsproj"
)

Target "NuGetNUnitCore" (fun _ ->
// Rebuild project and pack (create NuGet package)
let nunitDir, nunitProj = "src/FsUnit.NUnit", "FsUnit.NUnit.netstandard.fsproj"
DotNetCli.Restore (fun c -> { c with WorkingDir = nunitDir; Project = nunitProj })
DotNetCli.Build (fun c -> { c with WorkingDir = nunitDir; Project = nunitProj })
DotNetCli.RunCommand (fun c -> { c with WorkingDir = nunitDir})
(sprintf "pack \"%s\" /p:Version=%s --configuration Release" nunitProj (release.NugetVersion))
Target "xUnitCore" (fun _ ->
buildNetCoreLibrary "tests/FsUnit.Xunit.Test" "FsUnit.Xunit.Test.netcoreapp.fsproj"
)

Target "MSTestCore" (fun _ ->
buildNetCoreLibrary "tests/FsUnit.MsTest.Test" "Fs30Unit.MsTest.Test.netcoreapp.fsproj"
)

// Restore dotnet-mergenupkg and merge two packages
Target "NuGetNetCore" (fun _ ->
let toolsDir = "tools/"
DotNetCli.Restore (fun c -> { c with WorkingDir = toolsDir})

let nupkg = sprintf "FsUnit.%s.nupkg" release.NugetVersion
DotNetCli.RunCommand (fun c -> { c with WorkingDir = toolsDir})
(sprintf "mergenupkg --source \"./../bin/%s\" --other \"./../src/FsUnit.NUnit/bin/Release/%s\" --framework netstandard1.6" nupkg nupkg)
)
let buildPackage projectDir projectFile packageNameTemplate =
DotNetCli.Restore (fun c -> { c with WorkingDir = projectDir; Project = projectFile })
DotNetCli.Build (fun c -> { c with WorkingDir = projectDir; Project = projectFile })
DotNetCli.RunCommand (fun c -> { c with WorkingDir = projectDir })
(sprintf "pack \"%s\" /p:Version=%s --configuration Release" projectFile (release.NugetVersion))

let nupkg = sprintf packageNameTemplate release.NugetVersion
DotNetCli.RunCommand (fun c -> { c with WorkingDir = toolsDir })
(sprintf "mergenupkg --source \"./../bin/%s\" --other \"./../%s/bin/Release/%s\" --framework netstandard1.6" nupkg projectDir nupkg)

DotNetCli.Restore (fun c -> { c with WorkingDir = toolsDir })

//NUnit
buildPackage "src/FsUnit.NUnit" "FsUnit.NUnit.netstandard.fsproj" "FsUnit.%s.nupkg"

//xUnit
buildPackage "src/FsUnit.Xunit" "FsUnit.Xunit.netstandard.fsproj" "FsUnit.xUnit.%s.nupkg"

//MSTest
buildPackage "src/FsUnit.MsTestUnit" "FsUnit.MsTest.netstandard.fsproj" "Fs30Unit.MsTest.%s.nupkg"
)

// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override
Expand All @@ -384,14 +400,16 @@ Target "All" DoNothing

// .NET Standard and .NET Core support
"AssemblyInfo" ==> "NUnitCore" ==> "RunTests"
"AssemblyInfo" ==> "xUnitCore" ==> "RunTests"
"AssemblyInfo" ==> "MSTestCore" ==> "RunTests"

"All"
#if MONO
#else
// =?> ("SourceLink", Pdbstr.tryFind().IsSome )
#endif
==> "NuGet"
==> "NuGetNUnitCore"
==> "NuGetNetCore"
==> "BuildPackage"

"CleanDocs"
Expand Down
18 changes: 18 additions & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,21 @@ nuget mbunit 3.4.14

github fsharp/FAKE modules/Octokit/Octokit.fsx

clitool dotnet-mergenupkg >= 1.0.1

group netcore
source http://nuget.org/api/v2
framework: netstandard1.6, netcoreapp1.1

nuget FSharp.Core ~> 4.1
nuget FSharp.NET.Sdk ~> 1.0
nuget NHamcrest
nuget xunit
nuget System.Reflection.TypeExtensions
nuget Microsoft.NET.Test.Sdk
nuget xunit.runner.visualstudio
nuget MSTest.TestAdapter
nuget MSTest.TestFramework
nuget NUnit
nuget System.Collections.NonGeneric
nuget NUnit3TestAdapter
Loading