Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
refactor build script to build and run tests for both drivers. Remain…
…ing to deal with packaging.
  • Loading branch information
smoothdeveloper committed May 6, 2026
commit 55cccc18ad8f586b0249550a3341c0376f9e4153
81 changes: 47 additions & 34 deletions build/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,31 @@

// Information about the project to be used at NuGet and in AssemblyInfo files
let systemSqlProject = {|
runtime="FSharp.Data.SqlClient"
designTime="FSharp.Data.SqlClient.DesignTime"
runtime = "FSharp.Data.SqlClient"
designTime = "FSharp.Data.SqlClient.DesignTime"
slnPath = makeRootPath "SqlClient.sln"
testProjectsSlnPath = makeRootPath "TestProjects.sln"
testSlnPath = makeRootPath "Tests.sln"
testProjectPath = makeRootPath "tests/SqlClient.Tests/SqlClient.Tests.fsproj"

|}
let microsoftSqlProject = {|
runtime="FSharp.Data.MicrosoftSqlClient"
designTime="FSharp.Data.MicrosoftSqlClient.DesignTime"
runtime = "FSharp.Data.MicrosoftSqlClient"
designTime = "FSharp.Data.MicrosoftSqlClient.DesignTime"
slnPath = makeRootPath "MicrosoftSqlClient.sln"
testProjectsSlnPath = makeRootPath "MicrosoftTestProjects.sln"
testSlnPath = makeRootPath "MicrosoftTests.sln"
testProjectPath = makeRootPath "tests/SqlClient.Tests/MicrosoftSqlClient.Tests.fsproj"
|}

let projects = [systemSqlProject;microsoftSqlProject]
let authors = ["Dmitry Morozov, Dmitry Sevastianov"]
let summary = "SqlClient F# type providers"
let description = "SqlCommandProvider provides statically typed access to input parameters and result set of T-SQL command in idiomatic F# way.\nSqlProgrammabilityProvider exposes Stored Procedures, User-Defined Types and User-Defined Functions in F# code."
let description = """SqlCommandProvider provides statically typed access to input parameters and result set of T-SQL command in idiomatic F# way.
SqlProgrammabilityProvider exposes Stored Procedures, User-Defined Types and User-Defined Functions in F# code.
"""
let tags = "F# fsharp data typeprovider sql"

let gitHome = "https://github.com/fsprojects"
let gitName = "FSharp.Data.SqlClient"

Expand Down Expand Up @@ -98,11 +111,7 @@
AssemblyInfo.InternalsVisibleTo "MicrosoftSqlClient.Tests" ] )
)

let slnPath = makeRootPath "SqlClient.sln"
let testProjectsSlnPath = makeRootPath "TestProjects.sln"
let testSlnPath = makeRootPath "Tests.sln"
let testDir = makeRootPath "tests"
let testProjectPath = makeRootPath "tests/SqlClient.Tests/SqlClient.Tests.fsproj"

let msBuildPaths extraPaths =
[
Expand Down Expand Up @@ -158,10 +167,10 @@
Target.create "Clean" (fun _ ->
Shell.cleanDirs ["bin"; "temp"]
let dnDefault (args: DotNet.Options) = { args with Verbosity = Some DotNet.Verbosity.Quiet }
DotNet.exec dnDefault "clean" slnPath |> ignore
DotNet.exec dnDefault "clean" testProjectsSlnPath |> ignore
DotNet.exec dnDefault "clean" testSlnPath |> ignore
()
for entry in projects do
DotNet.exec dnDefault "clean" entry.slnPath |> ignore
DotNet.exec dnDefault "clean" entry.testProjectsSlnPath |> ignore
DotNet.exec dnDefault "clean" entry.testSlnPath |> ignore
)

Target.create "CleanDocs" (fun _ ->
Expand All @@ -179,9 +188,10 @@
>> DotNet.Options.withCustomParams (Some "--tl")

Target.create "Build" (fun _ ->
for entry in projects do
DotNet.build
(fun args -> { args with Configuration = DotNet.Release } |> dnDefault)
slnPath
(fun args -> { args with Configuration = DotNet.Release } |> dnDefault)
entry.slnPath
)

open System.Data.SqlClient
Expand Down Expand Up @@ -218,12 +228,12 @@
.ConnectionString <- gitHubActionSqlConnectionString
testConfigFile.Save()
gitHubActionSqlConnectionString
SqlConnectionStringBuilder connStr

Check warning on line 231 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.
testConnStr <- Some connStr
database <- Some connStr.InitialCatalog

Check warning on line 233 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.
conn <-
connStr.InitialCatalog <- ""

Check warning on line 235 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.
let cnx = new SqlConnection(string connStr)

Check warning on line 236 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.

Check warning on line 236 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.
cnx.Open()
Some cnx
)
Expand All @@ -235,7 +245,7 @@
//attach
let dbIsMissing =
let query = sprintf "SELECT COUNT(*) FROM sys.databases WHERE name = '%s'" database.Value
use cmd = new SqlCommand(query, conn.Value)

Check warning on line 248 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.

Check warning on line 248 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.
cmd.ExecuteScalar() = box 0

if dbIsMissing then
Expand All @@ -248,13 +258,13 @@
ZipFile.ExtractToDirectory(testsSourceRoot @@ (dataFileName + ".zip"), testsSourceRoot)

let dataPath =
use cmd = new SqlCommand("SELECT SERVERPROPERTY('InstanceDefaultDataPath')", conn.Value)

Check warning on line 261 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.

Check warning on line 261 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.
cmd.ExecuteScalar() |> string
do
let destFileName = dataPath @@ Path.GetFileName(sourceMdf)
File.Copy(sourceMdf, destFileName, overwrite = true)
File.Delete( sourceMdf)
use cmd = conn.Value.CreateCommand(CommandText = sprintf "CREATE DATABASE [%s] ON ( FILENAME = N'%s' ) FOR ATTACH" database.Value destFileName)

Check warning on line 267 in build/build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. Use the Microsoft.Data.SqlClient package instead.
cmd.ExecuteNonQuery() |> ignore
)
}
Expand Down Expand Up @@ -291,42 +301,45 @@
}

Target.create "BuildTestProjects" (fun _ ->
pipeline "BuildTestProjects" {
funBuildRestore "test projects sln" testProjectsSlnPath
funBuildRunMSBuild "test projects sln" testProjectsSlnPath
for entry in projects do
if File.Exists entry.testProjectsSlnPath then
pipeline $"BuildTestProjects {entry.runtime}" {
funBuildRestore "test projects sln" entry.testProjectsSlnPath
funBuildRunMSBuild "test projects sln" entry.testProjectsSlnPath
runImmediate
}
}
)

// --------------------------------------------------------------------------------------
// Run the unit tests
Target.create "RunTests" (fun _ ->

let runTests () =
let runTests (entry: {|testSlnPath: string; testProjectPath: string|}) =
let dnTestOptions framework (args: DotNet.TestOptions) =
{ args with
Framework = Some framework
Common = args.Common
NoBuild = true
MSBuildParams = { args.MSBuildParams with DisableInternalBinLog = true }
}
try
DotNet.test (dnTestOptions "net462") testSlnPath
DotNet.test (dnTestOptions "net8.0") testProjectPath

try
DotNet.test (dnTestOptions "net462") entry.testSlnPath
DotNet.test (dnTestOptions "net8.0") entry.testProjectPath
with
| ex ->
Trace.log (sprintf "Test exception: %A" ex)
raise ex

pipeline "RunTests" {
funBuildRestore "test sln" testSlnPath
funBuildRunMSBuild "test sln" testSlnPath

stage "run tests" {
run (fun ctx -> runTests())
}
runImmediate
}
for entry in projects do
pipeline $"RunTests {entry.runtime}" {
funBuildRestore "test sln" entry.testSlnPath
funBuildRunMSBuild "test sln" entry.testSlnPath
stage "run tests" {
run (fun ctx -> runTests {|testSlnPath=entry.testSlnPath; testProjectPath=entry.testProjectPath|})
}
runImmediate
}
)

// --------------------------------------------------------------------------------------
Expand Down
Loading