1+ open Fake.DotNet
12// --------------------------------------------------------------------------------------
23// FAKE build script
34// --------------------------------------------------------------------------------------
@@ -25,6 +26,7 @@ let files includes =
2526
2627// Information about the project to be used at NuGet and in AssemblyInfo files
2728let project = " FSharp.Data.SqlClient"
29+ let designTimeProject = " FSharp.Data.SqlClient.DesignTime"
2830let authors = [ " Dmitry Morozov, Dmitry Sevastianov" ]
2931let summary = " SqlClient F# type providers"
3032let description = " SqlCommandProvider provides statically typed access to input parameters and result set of T-SQL command in idiomatic F# way.\n SqlProgrammabilityProvider exposes Stored Procedures, User-Defined Types and User-Defined Functions in F# code."
@@ -40,7 +42,9 @@ let release =
4042
4143let version = release.AssemblyVersion
4244let releaseNotes = release.Notes |> String.concat " \n "
43- let testDir = " bin"
45+
46+ let install = lazy DotNet.install DotNet.Versions.Release_ 2_ 1_ 402
47+ let inline dnDefault arg = DotNet.Options.lift install.Value arg
4448
4549// --------------------------------------------------------------------------------------
4650// Generate assembly info files with the right version & up-to-date information
@@ -55,24 +59,44 @@ Target.create "AssemblyInfo" (fun _ ->
5559 AssemblyInfo.Version version
5660 AssemblyInfo.FileVersion version
5761 AssemblyInfo.InternalsVisibleTo " SqlClient.Tests" ] )
62+
63+ [ " src/SqlClient.DesignTime/AssemblyInfo.fs" , " SqlClient.DesignTime" , designTimeProject, summary ]
64+ |> Seq.iter ( fun ( fileName , title , project , summary ) ->
65+ AssemblyInfoFile.createFSharp fileName
66+ [ AssemblyInfo.Title title
67+ AssemblyInfo.Product project
68+ AssemblyInfo.Description summary
69+ AssemblyInfo.Version version
70+ AssemblyInfo.FileVersion version
71+ AssemblyInfo.InternalsVisibleTo " SqlClient.Tests" ] )
5872)
5973
74+ let slnPath = " SqlClient.sln"
75+ let testProjectsSlnPath = " TestProjects.sln"
76+ let testSlnPath = " Tests.sln"
77+ let testProjectPath = " tests/SqlClient.Tests/SqlClient.Tests.fsproj"
78+
6079Target.create " Clean" ( fun _ ->
6180 Shell.cleanDirs [ " bin" ; " temp" ]
81+ DotNet.exec dnDefault " clean" slnPath |> ignore
82+ DotNet.exec dnDefault " clean" testProjectsSlnPath |> ignore
83+ DotNet.exec dnDefault " clean" testSlnPath |> ignore
6284)
6385
6486Target.create " CleanDocs" ( fun _ ->
6587 Shell.cleanDirs [ " docs/output" ]
6688)
6789
68- // --------------------------------------------------------------------------------------
69- // Build library (builds Visual Studio solution, which builds multiple versions
70- // of the runtime library & desktop + Silverlight version of design time library)
71-
7290Target.create " Build" ( fun _ ->
73- files ([ " SqlClient.sln" ])
74- |> MSBuild.runRelease id " " " Rebuild"
75- |> ignore
91+ DotNet.build
92+ ( fun args ->
93+ {
94+ args with
95+ Configuration = DotNet.Release
96+ //Common = { args.Common with Verbosity = Some DotNet.Verbosity.Detailed }
97+ } |> dnDefault)
98+ slnPath
99+
76100)
77101
78102#r " System.Data"
@@ -86,7 +110,7 @@ open System.Configuration
86110open System.IO .Compression
87111
88112Target.create " DeployTestDB" ( fun _ ->
89- let testsSourceRoot = Path.GetFullPath( @" src \SqlClient.Tests" )
113+ let testsSourceRoot = Path.GetFullPath( @" tests \SqlClient.Tests" )
90114 let map = ExeConfigurationFileMap()
91115 map.ExeConfigFilename <- testsSourceRoot @@ " app.config"
92116 let connStr =
@@ -140,23 +164,29 @@ Target.create "DeployTestDB" (fun _ ->
140164 cmd.ExecuteNonQuery() |> ignore
141165)
142166
143- Target.create " BuildTests" ( fun _ ->
144- files [ " Tests.sln" ]
145- |> MSBuild.runReleaseExt id " " ([]) " Rebuild"
146- |> ignore
167+ Target.create " BuildTestProjects" ( fun _ ->
168+ DotNet.build
169+ ( fun args ->
170+ {
171+ args with
172+ Configuration = DotNet.Release
173+ //Common = { args.Common with Verbosity = Some DotNet.Verbosity.Detailed }
174+ } |> dnDefault)
175+ testProjectsSlnPath
147176)
148177
149178// --------------------------------------------------------------------------------------
150179// Run the unit tests
151- Target.create " RunTests" ( fun _ ->
152- !! ( testDir + " /*.Tests.dll" )
153- |> Fake.XUnitHelper.xUnit ( fun p ->
154- { p with
155- ShadowCopy = false
156- HtmlOutput = true
157- XmlOutput = true
158- WorkingDir = testDir
159- })
180+ Target.create " RunTests" ( fun _ ->
181+ // if we don't compile the targets sequentially, we get an error with the generated types:
182+ // System.IO.IOException: The process cannot access the file 'C:\Users\foo\AppData\Local\Temp\tmpF38.dll' because it is being used by another process.
183+ try
184+ DotNet.test ( fun args -> { args with Framework = Some " net461" ; Common = args.Common |> dnDefault }) testSlnPath
185+ DotNet.test ( fun args -> { args with Framework = Some " netcoreapp2.0" ; Common = args.Common |> dnDefault }) testProjectPath
186+ with
187+ | ex ->
188+ Trace.log ( sprintf " Test exception: %A " ex)
189+ raise ex
160190)
161191
162192// --------------------------------------------------------------------------------------
@@ -219,8 +249,8 @@ open Fake.Core.TargetOperators // for ==>
219249" Clean"
220250 ==> " AssemblyInfo"
221251 ==> " Build"
222- ==> " DeployTestDB "
223- ==> " BuildTests "
252+ ==> " BuildTestProjects "
253+ ==> " DeployTestDB "
224254 ==> " RunTests"
225255 ==> " All"
226256
@@ -234,4 +264,3 @@ open Fake.Core.TargetOperators // for ==>
234264 ==> " ReleaseDocs"
235265
236266Target.runOrDefault " All"
237-
0 commit comments