33// --------------------------------------------------------------------------------------
44
55#I " packages/FAKE/tools"
6- #r " FakeLib.dll"
6+
7+ #r " packages/FAKE/tools/FakeLib.dll"
78
89open System
910open System.IO
10- open Fake.AssemblyInfoFile
11- open Fake.Git
12- open Fake.Testing
13- open Fake.FscHelper
1411open Fake
1512
16-
1713// --------------------------------------------------------------------------------------
1814// Information about the project to be used at NuGet
1915// --------------------------------------------------------------------------------------
@@ -28,12 +24,19 @@ let tags = "F# fsharp typeprovider"
2824let gitHome = " https://github.com/fsprojects"
2925let gitName = " FSharp.TypeProviders.SDK"
3026
27+ let config = " Release"
28+
3129// Read release notes & version info from RELEASE_NOTES.md
3230Environment.CurrentDirectory <- __ SOURCE_ DIRECTORY__
3331let 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+
3740let pullRequest =
3841 match getBuildParamOrDefault " APPVEYOR_PULL_REQUEST_NUMBER" " " with
3942 | " " ->
@@ -44,21 +47,16 @@ let pullRequest =
4447 Some <| int a
4548
4649let buildNumber =
47- int ( getBuildParamOrDefault " APPVEYOR_BUILD_VERSION" " 0" )
50+ getBuildParamOrDefault " APPVEYOR_BUILD_VERSION" " 0"
4851
4952let 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
5558let releaseNotes = release.Notes |> String.concat " \n "
56- let outputPath = " ./output/"
57- let workingDir = " ./temp/"
5859let srcDir = " src"
59- let exampleDir = " examples"
60- let testDir = " test"
61- let nunitDir = " packages/NUnit/lib/net45"
6260
6361let 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-
7569Target " 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+ )
8176Target " 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
14591Target " 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-
158104Target " 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
0 commit comments