Skip to content

Commit ac405ce

Browse files
authored
Merge pull request #132 from dsyme/sdk
Move to use dotnet CLI 2.0
2 parents 40bfff9 + 4822f5f commit ac405ce

19 files changed

+187
-440
lines changed

.travis.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
language: csharp
22

33
mono:
4-
- beta
5-
- latest
6-
- 4.8.1
7-
- 4.2.2
8-
- 4.0.5
4+
- weekly
5+
- nightly
6+
7+
# beta doesn't work because of whacky msbuild package install problems
8+
# beta
9+
10+
# 5.4.0 doesn't work because of missing SDK build things for F# new styleprojects + msbuild
11+
# - latest
12+
13+
# 5.2.0 doesn't work because of missing SDK build things for F# new styleprojects + msbuild
14+
# - 5.2.0
15+
16+
dotnet: 2.0.0
917

1018
os:
1119
- linux
1220
- osx
1321

14-
matrix:
15-
allow_failures:
16-
- mono: beta
17-
18-
sudo: false # use the new container-based Travis infrastructure
22+
sudo: true # use the new container-based Travis infrastructure
1923

2024
script:
2125
- ./build.sh RunTests

build.fsx

Lines changed: 46 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
// --------------------------------------------------------------------------------------
44

55
#I "packages/FAKE/tools"
6-
#r "FakeLib.dll"
6+
7+
#r "packages/FAKE/tools/FakeLib.dll"
78

89
open System
910
open System.IO
10-
open Fake.AssemblyInfoFile
11-
open Fake.Git
12-
open Fake.Testing
13-
open Fake.FscHelper
1411
open Fake
1512

16-
1713
// --------------------------------------------------------------------------------------
1814
// Information about the project to be used at NuGet
1915
// --------------------------------------------------------------------------------------
@@ -28,12 +24,19 @@ let tags = "F# fsharp typeprovider"
2824
let gitHome = "https://github.com/fsprojects"
2925
let gitName = "FSharp.TypeProviders.SDK"
3026

27+
let config = "Release"
28+
3129
// Read release notes & version info from RELEASE_NOTES.md
3230
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
3331
let release =
3432
File.ReadLines "RELEASE_NOTES.md"
3533
|> ReleaseNotesHelper.parseReleaseNotes
3634

35+
36+
let exec p args =
37+
printfn "Executing %s %s" p args
38+
Shell.Exec(p, args) |> function 0 -> () | d -> failwithf "%s %s exited with error %d" p args d
39+
3740
let pullRequest =
3841
match getBuildParamOrDefault "APPVEYOR_PULL_REQUEST_NUMBER" "" with
3942
| "" ->
@@ -44,21 +47,16 @@ let pullRequest =
4447
Some <| int a
4548

4649
let buildNumber =
47-
int (getBuildParamOrDefault "APPVEYOR_BUILD_VERSION" "0")
50+
getBuildParamOrDefault "APPVEYOR_BUILD_VERSION" "0"
4851

4952
let version =
5053
match pullRequest with
5154
| None ->
52-
sprintf "%s.%d" release.AssemblyVersion buildNumber
55+
sprintf "%s.%s" release.AssemblyVersion buildNumber
5356
| Some num ->
54-
sprintf "%s-pull-%d-%05d" release.AssemblyVersion num buildNumber
57+
sprintf "%s-pull-%d-%s" release.AssemblyVersion num buildNumber
5558
let releaseNotes = release.Notes |> String.concat "\n"
56-
let outputPath = "./output/"
57-
let workingDir = "./temp/"
5859
let srcDir = "src"
59-
let exampleDir = "examples"
60-
let testDir = "test"
61-
let nunitDir = "packages/NUnit/lib/net45"
6260

6361
let sources =
6462
[srcDir @@ "ProvidedTypes.fsi"
@@ -68,124 +66,57 @@ let sources =
6866
srcDir @@ "ProvidedTypesContext.fs"
6967
srcDir @@ "ProvidedTypesTesting.fs" ]
7068

71-
72-
// --------------------------------------------------------------------------------------
73-
// Clean build results
74-
7569
Target "Clean" (fun _ ->
76-
CleanDirs [outputPath; workingDir]
70+
CleanDirs []
7771
)
7872

79-
// --------------------------------------------------------------------------------------
80-
// Compile ProvidedTypes as a smoke test
73+
Target "Restore" (fun _ ->
74+
exec "dotnet" "restore"
75+
)
8176
Target "Compile" (fun _ ->
82-
// sources
83-
// |> Compile [
84-
// FscHelper.Target TargetType.Library
85-
// Platform PlatformType.AnyCpu
86-
// Reference "System.Reflection.Metadata.dll"
87-
// ]
88-
89-
!! "FSharp.TypeProviders.SDK.sln"
90-
|> MSBuildRelease "" "Build"
91-
|> ignore
77+
#if MONO
78+
// We don't use dotnet build because of https://github.com/dotnet/sdk/issues/335
79+
exec "msbuild" ("src/FSharp.TypeProviders.SDK.fsproj /p:Configuration=" + config)
80+
exec "msbuild" ("tests/FSharp.TypeProviders.SDK.Tests.fsproj /p:Configuration=" + config)
81+
#else
82+
exec "dotnet" "build"
83+
#endif
9284
)
9385

94-
type ExampleWithTests =
95-
{ Name : string
96-
ProviderSourceFiles : string list
97-
TestSourceFiles : string list }
98-
99-
100-
// --------------------------------------------------------------------------------------
101-
// Compile example providers and accompanying test dlls
102-
#if EXAMPLES
103-
Target "Examples" (fun _ ->
104-
let examples =
105-
[
106-
{ Name = "StaticProperty"; ProviderSourceFiles = ["StaticProperty.fsx"]; TestSourceFiles = ["StaticProperty.Tests.fsx"]}
107-
{ Name = "ErasedWithConstructor"; ProviderSourceFiles = ["ErasedWithConstructor.fsx"]; TestSourceFiles = ["ErasedWithConstructor.Tests.fsx"]}
108-
]
109-
110-
if not (Directory.Exists testDir) then
111-
Directory.CreateDirectory testDir |> ignore
112-
113-
let testNunitDll = testDir @@ "nunit.framework.dll"
114-
115-
if File.Exists testNunitDll then
116-
File.Delete testNunitDll
117-
118-
File.Copy (nunitDir @@ "nunit.framework.dll", testNunitDll)
119-
120-
let fromExampleDir filenames =
121-
filenames
122-
|> List.map (fun filename -> exampleDir @@ filename)
123-
124-
examples
125-
|> List.iter (fun example ->
126-
// Compile type provider
127-
let output = testDir @@ example.Name + ".dll"
128-
(List.concat [sources;fromExampleDir example.ProviderSourceFiles])
129-
|> Compile [
130-
Out output
131-
FscHelper.Target TargetType.Library
132-
]
133-
134-
// Compile test dll
135-
(fromExampleDir example.TestSourceFiles)
136-
|> Compile [
137-
Out (testDir @@ example.Name + ".Tests.dll")
138-
FscHelper.Target TargetType.Library
139-
References [output;nunitDir @@ "nunit.framework.dll"]
140-
]
141-
)
142-
)
143-
#endif
86+
//#if EXAMPLES
87+
// { Name = "StaticProperty"; ProviderSourceFiles = ["StaticProperty.fsx"]; TestSourceFiles = ["StaticProperty.Tests.fsx"]}
88+
// { Name = "ErasedWithConstructor"; ProviderSourceFiles = ["ErasedWithConstructor.fsx"]; TestSourceFiles = ["ErasedWithConstructor.Tests.fsx"]}
89+
//#endif
14490

14591
Target "RunTests" (fun _ ->
146-
!! ("tests/bin/Release/FSharp.TypeProviders.SDK.Tests.dll")
147-
|> NUnit3 id
148-
149-
#if EXAMPLES
150-
!! (testDir @@ "*.Tests.dll")
151-
|> NUnit3 id
92+
#if MONO
93+
// We don't use dotnet test because of https://github.com/dotnet/sdk/issues/335
94+
//exec "packages/xunit.runner.console/tools/net452/xunit.console.exe" ("/p:Configuration=" + config + " tests/bin/" + config + "/net461/FSharp.TypeProviders.SDK.Tests.dll -parallel none")
95+
()
96+
#else
97+
exec "dotnet" ("test tests/FSharp.TypeProviders.SDK.Tests.fsproj -c " + config)
98+
// This also gives console output:
99+
//exec "packages/xunit.runner.console/tools/net452/xunit.console.exe" ("/p:Configuration=" + config + " tests/bin/" + config + "/net461/FSharp.TypeProviders.SDK.Tests.dll -parallel none")
152100
#endif
101+
()
153102
)
154103

155-
// --------------------------------------------------------------------------------------
156-
// Build a NuGet package
157-
158104
Target "NuGet" (fun _ ->
159-
sources |> CopyTo (workingDir @@ "content")
160-
161-
NuGet (fun p ->
162-
{ p with
163-
Authors = authors
164-
Project = project
165-
Summary = summary
166-
Description = description
167-
Version = version
168-
ReleaseNotes = releaseNotes
169-
Tags = tags
170-
OutputPath = outputPath
171-
WorkingDir = workingDir
172-
AccessKey = getBuildParamOrDefault "nugetkey" ""
173-
Publish = hasBuildParam "nugetkey"
174-
Files = [(workingDir, None, None)]
175-
Dependencies = [] })
176-
"nuget/FSharp.TypeProviders.SDK.nuspec"
105+
#if !MONO
106+
// We don't do this on Linux/OSX because of https://github.com/dotnet/sdk/issues/335
107+
exec "dotnet" ("pack src/FSharp.TypeProviders.SDK.fsproj -c " + config)
108+
#endif
109+
()
177110
)
178111

179-
// --------------------------------------------------------------------------------------
180-
// Help
181-
182112
"Clean"
183113
==> "NuGet"
184114

185-
"Compile"
186-
#if EXAMPLES
187-
==> "Examples"
188-
#endif
115+
"Restore"
116+
==> "Compile"
117+
//#if EXAMPLES
118+
// ==> "Examples"
119+
//#endif
189120
==> "RunTests"
190121
==> "NuGet"
191122

build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ then
1212
else
1313
# use mono
1414

15+
sudo apt-get -y install msbuild mono-complete mono-devel fsharp
16+
1517
which mono
16-
find /usr/lib/mono
18+
which dotnet
19+
which msbuild
1720

1821
mono .paket/paket.exe restore
1922
exit_code=$?
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#if INTERACTIVE
2-
#r @"../packages/NUnit/lib/net45/nunit.framework.dll"
32
#r @"../test/ErasedWithConstructor.dll"
43
#endif
54

6-
open NUnit.Framework
75
open ErasedWithConstructor.Provided
6+
open Xunit
87

9-
[<Test>]
8+
[<Fact>]
109
let ``Default constructor should create instance`` () =
11-
Assert.AreEqual("My internal state", MyType().InnerState)
10+
Assert.Equal("My internal state", MyType().InnerState)
1211

13-
[<Test>]
12+
[<Fact>]
1413
let ``Constructor with parameter should create instance`` () =
15-
Assert.AreEqual("override", MyType("override").InnerState)
14+
Assert.Equal("override", MyType("override").InnerState)
1615

examples/StaticProperty.Tests.fsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#if INTERACTIVE
2-
#r @"../packages/NUnit/lib/net45/nunit.framework.dll"
32
#r @"../test/StaticProperty.dll"
43
#endif
54

6-
open NUnit.Framework
75
open StaticProperty.Provided
86

9-
[<Test>]
7+
[<Fact>]
108
let ``Static property should have been created`` () =
11-
Assert.AreEqual("Hello world", MyType.MyProperty)
9+
Assert.Equal("Hello world", MyType.MyProperty)
1210

paket.dependencies

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ source https://api.nuget.org/v3/index.json
33

44
nuget Nuget.CommandLine
55
nuget FAKE
6-
7-
nuget NUnit
8-
nuget NUnit.ConsoleRunner
6+
nuget xunit.runner.console
97

108
group fs31
119
source https://api.nuget.org/v3/index.json

paket.lock

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
RESTRICTION: >= net45
22
NUGET
33
remote: https://api.nuget.org/v3/index.json
4-
FAKE (4.63)
4+
FAKE (4.63.2)
55
Nuget.CommandLine (4.3)
6-
NUnit (3.7.1)
7-
NUnit.ConsoleRunner (3.7)
6+
xunit.runner.console (2.3)
87

98
GROUP fs31
109
NUGET

0 commit comments

Comments
 (0)