Skip to content

Commit a079d0a

Browse files
authored
Merge pull request #2 from vbfox/SDK-&&-.Net-Core
Sdk && .net core
2 parents b20daea + 0db1e4b commit a079d0a

30 files changed

+1526
-905
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ publish/
149149
*.nupkg
150150
# The packages folder can be ignored because of Package Restore
151151
**/packages/*
152-
# except build/, which is used as an MSBuild target.
153-
!**/packages/build/
154152
# Uncomment if necessary however generally it will be regenerated when needed
155153
#!**/packages/repositories.config
156154
# NuGet v3's project.json files produces more ignoreable files

.paket/Paket.Restore.targets

Lines changed: 276 additions & 0 deletions
Large diffs are not rendered by default.

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
language: csharp
22

3+
addons:
4+
apt:
5+
sources:
6+
- ubuntu-toolchain-r-test
7+
packages:
8+
- libstdc++-4.9-dev
9+
- libunwind8-dev
10+
311
script:
412
- ./build.sh CI
513

Release Notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### New in 1.0.0
2+
3+
* The library now targets .Net 4.0, .Net standard 1.6 and .Net standard 2.0
4+
15
### New in 0.2.1
26

37
* NuGet package was accidentally dependent on FSharpLint.MSBuild

build.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ if errorlevel 1 (
55
exit /b %errorlevel%
66
)
77

8-
packages\FAKE\tools\FAKE.exe build\build.fsx %*
8+
packages\build\FAKE\tools\FAKE.exe build\build.fsx %*

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
function dotnet { if test "$OS" = "Windows_NT"; then $@; else mono $@; fi }
44

55
./paket.sh restore || { exit $?; }
6-
dotnet packages/FAKE/tools/FAKE.exe $@ --fsiargs build/build.fsx
6+
dotnet packages/build/FAKE/tools/FAKE.exe $@ --fsiargs build/build.fsx

build/AppVeyorEx.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module BlackFox.AppVeyorEx
22

3-
#r "../packages/FAKE/tools/FakeLib.dll"
3+
#r "../packages/build/FAKE/tools/FakeLib.dll"
44
#load "./CmdLine.fs"
55

66
open BlackFox.CommandLine

build/TaskDefinitionHelper.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#r "../packages/FAKE/tools/FakeLib.dll"
1+
#r "../packages/build/FAKE/tools/FakeLib.dll"
22

33
namespace BlackFox
44

build/build.fsx

Lines changed: 101 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// include Fake libs
2-
#r "../packages/FAKE/tools/FakeLib.dll"
2+
#r "../packages/build/FAKE/tools/FakeLib.dll"
3+
#r "System.Xml.Linq"
34
#load "./TaskDefinitionHelper.fsx"
45
#load "./AppVeyorEx.fsx"
56

67
open System
8+
open System.Xml.Linq
79
open Fake
10+
open Fake.AssemblyInfoFile
811
open Fake.ReleaseNotesHelper
9-
open Fake.Testing.NUnit3
12+
open Fake.Testing.Expecto
1013
open BlackFox
1114

1215
let configuration = environVarOrDefault "configuration" "Release"
@@ -16,9 +19,8 @@ let from s = { BaseDirectory = s; Includes = []; Excludes = [] }
1619
let rootDir = System.IO.Path.GetFullPath(__SOURCE_DIRECTORY__ </> "..")
1720
let srcDir = rootDir </> "src"
1821
let artifactsDir = rootDir </> "artifacts"
19-
let binDir = artifactsDir </> "bin"
2022
let librarySrcDir = srcDir </> "BlackFox.MasterOfFoo"
21-
let libraryBinDir = binDir </> "BlackFox.MasterOfFoo" </> configuration
23+
let libraryBinDir = artifactsDir </> "BlackFox.MasterOfFoo" </> configuration
2224
let projects = from srcDir ++ "**/*.*proj"
2325

2426
/// The profile where the project is posted
@@ -31,63 +33,130 @@ let gitName = "MasterOfFoo"
3133
/// The url for the raw files hosted
3234
let gitRaw = environVarOrDefault "gitRaw" ("https://raw.github.com/" + gitOwner)
3335

36+
let inline versionPartOrZero x = if x < 0 then 0 else x
37+
3438
let release =
3539
let fromFile = LoadReleaseNotes (rootDir </> "Release Notes.md")
3640
if buildServer = AppVeyor then
3741
let appVeyorBuildVersion = int appVeyorBuildVersion
3842
let nugetVer = sprintf "%s-appveyor%04i" fromFile.NugetVersion appVeyorBuildVersion
3943
let asmVer = System.Version.Parse(fromFile.AssemblyVersion)
40-
let asmVer = System.Version(asmVer.Major, asmVer.Minor, asmVer.Build, appVeyorBuildVersion)
44+
let asmVer =
45+
System.Version(
46+
versionPartOrZero asmVer.Major,
47+
versionPartOrZero asmVer.Minor,
48+
versionPartOrZero asmVer.Build,
49+
versionPartOrZero appVeyorBuildVersion)
4150
ReleaseNotes.New(asmVer.ToString(), nugetVer, fromFile.Date, fromFile.Notes)
4251
else
4352
fromFile
4453

54+
let mutable dotnetExePath = "dotnet"
55+
56+
Task "InstallDotNetCore" [] (fun _ ->
57+
dotnetExePath <- DotNetCli.InstallDotNetSDK (DotNetCli.GetDotNetSDKVersionFromGlobalJson())
58+
)
59+
4560
AppVeyorEx.updateBuild (fun info -> { info with Version = Some release.AssemblyVersion })
4661

62+
let writeVersionProps() =
63+
let doc =
64+
XDocument(
65+
XElement(XName.Get("Project"),
66+
XElement(XName.Get("PropertyGroup"),
67+
XElement(XName.Get "Version", release.NugetVersion),
68+
XElement(XName.Get "PackageReleaseNotes", toLines release.Notes))))
69+
let path = artifactsDir </> "Version.props"
70+
System.IO.File.WriteAllText(path, doc.ToString())
71+
4772
Task "Init" [] <| fun _ ->
4873
CreateDir artifactsDir
74+
writeVersionProps ()
75+
CreateFSharpAssemblyInfo (artifactsDir </> "Version.fs") [Attribute.Version release.AssemblyVersion]
4976

50-
// Targets
5177
Task "Clean" ["Init"] <| fun _ ->
52-
CleanDirs [artifactsDir]
53-
54-
Task "Build" ["Init"; "?Clean"] <| fun _ ->
55-
MSBuild null "Build" ["Configuration", configuration] projects
56-
|> ignore
57-
58-
Task "RunTests" [ "Build"] <| fun _ ->
78+
let objDirs = projects |> Seq.map(fun p -> System.IO.Path.GetDirectoryName(p) </> "obj") |> List.ofSeq
79+
CleanDirs (artifactsDir :: objDirs)
80+
81+
Task "Build" ["InstallDotNetCore"; "Init"; "?Clean"] <| fun _ ->
82+
DotNetCli.Build
83+
(fun p ->
84+
{ p with
85+
WorkingDir = srcDir
86+
Configuration = configuration
87+
ToolPath = dotnetExePath })
88+
89+
module ExpectoDotNetCli =
90+
open System.Diagnostics
91+
92+
let Expecto (setParams : ExpectoParams -> ExpectoParams) (assemblies : string seq) =
93+
let args = setParams ExpectoParams.DefaultParams
94+
use __ = assemblies |> separated ", " |> traceStartTaskUsing "Expecto"
95+
let runAssembly testAssembly =
96+
let argsString = sprintf "\"%s\" %s" testAssembly (string args)
97+
let processTimeout = TimeSpan.MaxValue // Don't set a process timeout. The timeout is per test.
98+
let workingDir =
99+
if isNotNullOrEmpty args.WorkingDirectory
100+
then args.WorkingDirectory else DirectoryName testAssembly
101+
let exitCode =
102+
let info = ProcessStartInfo(dotnetExePath)
103+
info.WorkingDirectory <- workingDir
104+
info.Arguments <- argsString
105+
info.UseShellExecute <- false
106+
// Pass environment variables to the expecto console process in order to let it detect it's running on TeamCity
107+
// (it checks TEAMCITY_PROJECT_NAME <> null specifically).
108+
for name, value in environVars EnvironmentVariableTarget.Process do
109+
info.EnvironmentVariables.[string name] <- string value
110+
use proc = Process.Start(info)
111+
proc.WaitForExit() // Don't set a process timeout. The timeout is per test.
112+
proc.ExitCode
113+
testAssembly, exitCode
114+
let res =
115+
assemblies
116+
|> Seq.map runAssembly
117+
|> Seq.filter( snd >> (<>) 0)
118+
|> Seq.toList
119+
match res with
120+
| [] -> ()
121+
| failedAssemblies ->
122+
failedAssemblies
123+
|> List.map (fun (testAssembly,exitCode) -> sprintf "Expecto test of assembly '%s' failed. Process finished with exit code %d." testAssembly exitCode)
124+
|> String.concat System.Environment.NewLine
125+
|> FailedTestsException |> raise
126+
127+
Task "RunTests" ["Build"] <| fun _ ->
59128
let nunitPath = rootDir </> @"packages" </> "NUnit.ConsoleRunner" </> "tools" </> "nunit3-console.exe"
60129
let testAssemblies = artifactsDir </> "bin" </> "*.Tests" </> configuration </> "*.Tests.dll"
61130
let testResults = artifactsDir </> "TestResults.xml"
62131

63-
!! testAssemblies
64-
|> NUnit3 (fun p ->
65-
{p with
66-
ToolPath = nunitPath
67-
TimeOut = TimeSpan.FromMinutes 20.
68-
DisposeRunners = true
69-
ResultSpecs = [testResults] })
132+
[artifactsDir </> "BlackFox.MasterOfFoo.Tests" </> configuration </> "netcoreapp2.0" </> "BlackFox.MasterOfFoo.Tests.dll"]
133+
|> ExpectoDotNetCli.Expecto (fun p ->
134+
{ p with
135+
FailOnFocusedTests = true
136+
})
70137

71-
AppVeyor.UploadTestResultsFile AppVeyor.NUnit3 testResults
138+
let nupkgDir = artifactsDir </> "BlackFox.MasterOfFoo" </> configuration
72139

73140
Task "NuGet" ["Build"] <| fun _ ->
74-
Paket.Pack <| fun p ->
75-
{ p with
76-
OutputPath = artifactsDir
77-
Version = release.NugetVersion
78-
ReleaseNotes = toLines release.Notes
79-
WorkingDir = librarySrcDir
80-
BuildConfig = configuration
81-
BuildPlatform = "AnyCPU"}
82-
AppVeyor.PushArtifacts (from artifactsDir ++ "*.nupkg")
141+
DotNetCli.Pack
142+
(fun p ->
143+
{ p with
144+
WorkingDir = librarySrcDir
145+
Configuration = configuration
146+
ToolPath = dotnetExePath })
147+
let nupkg =
148+
nupkgDir
149+
</> (sprintf "BlackFox.MasterOfFoo.%s.nupkg" release.NugetVersion)
150+
151+
AppVeyor.PushArtifacts [nupkg]
83152

84153
Task "PublishNuget" ["NuGet"] <| fun _ ->
85154
let key =
86155
match environVarOrNone "nuget-key" with
87156
| Some(key) -> key
88157
| None -> getUserPassword "NuGet key: "
89158

90-
Paket.Push <| fun p -> { p with WorkingDir = artifactsDir; ApiKey = key }
159+
Paket.Push <| fun p -> { p with WorkingDir = nupkgDir; ApiKey = key }
91160

92161
let zipFile = artifactsDir </> (sprintf "BlackFox.MasterOfFoo-%s.zip" release.NugetVersion)
93162

@@ -99,7 +168,7 @@ Task "Zip" ["Build"] <| fun _ ->
99168
|> Zip libraryBinDir zipFile
100169
AppVeyor.PushArtifacts [zipFile]
101170

102-
#load "../paket-files/fsharp/FAKE/modules/Octokit/Octokit.fsx"
171+
#load "../paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
103172

104173
Task "GitHubRelease" ["Zip"] <| fun _ ->
105174
let user =

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "2.1.3"
4+
}
5+
}

0 commit comments

Comments
 (0)