diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml
index 4e95ce3d..387e2ce3 100644
--- a/.github/workflows/dotnet-core.yml
+++ b/.github/workflows/dotnet-core.yml
@@ -12,18 +12,18 @@ jobs:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
- name: Setup .NET Core
- uses: actions/setup-dotnet@v1
+ uses: actions/setup-dotnet@v3
with:
- dotnet-version: 7.0.400
+ dotnet-version: 8.0.100
- name: Install SQL Server
# reference @ https://github.com/Particular/install-sql-server-action
uses: Particular/install-sql-server-action@v1.0.0
with:
- connection-string-env-var: SQL_SERVER_CONNECTION_STRING
- catalog: AdventureWroks
+ connection-string-env-var: GITHUB_ACTION_SQL_SERVER_CONNECTION_STRING
+ catalog: AdventureWorks2012
extra-params: ""
- name: Build
env:
diff --git a/build/build.fs b/build/build.fs
index 29cb910b..a12334f4 100644
--- a/build/build.fs
+++ b/build/build.fs
@@ -141,6 +141,7 @@ let dotnetBuildDisableBinLog (args: DotNet.BuildOptions) =
let dnDefault =
dotnetBuildDisableBinLog
>> DotNet.Options.withVerbosity (Some DotNet.Verbosity.Quiet)
+ >> DotNet.Options.withCustomParams (Some "--tl")
Target.create "Build" (fun _ ->
DotNet.build
@@ -154,33 +155,55 @@ open System.IO.Compression
open Fake.DotNet.Testing
Target.create "DeployTestDB" (fun _ ->
- let testsSourceRoot = Path.GetFullPath(@"tests\SqlClient.Tests")
- let map = ExeConfigurationFileMap()
- map.ExeConfigFilename <- testsSourceRoot @@ "app.config"
- let connStr =
- let x =
- ConfigurationManager
- .OpenMappedExeConfiguration(map, ConfigurationUserLevel.None)
+ let testsSourceRoot = Path.GetFullPath(@"tests\SqlClient.Tests")
+ let mutable database = None
+ let mutable testConnStr = None
+ let mutable conn = None
+
+ pipeline "DeployTestDB" {
+
+ stage "adjust config file connection strings" {
+ run (fun ctx ->
+ let map = ExeConfigurationFileMap()
+ map.ExeConfigFilename <- testsSourceRoot @@ "app.config"
+ let testConfigFile = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None)
+ let connStr =
+ let connStr =
+ let gitHubActionSqlConnectionString = System.Environment.GetEnvironmentVariable "GITHUB_ACTION_SQL_SERVER_CONNECTION_STRING"
+ if String.IsNullOrWhiteSpace gitHubActionSqlConnectionString then
+ testConfigFile
.ConnectionStrings
.ConnectionStrings.["AdventureWorks"]
.ConnectionString
- SqlConnectionStringBuilder(x)
-
- let database = connStr.InitialCatalog
- use conn =
- connStr.InitialCatalog <- ""
- new SqlConnection(string connStr)
+ else
+ // we run under Github Actions, update the test config file connection string.
+ testConfigFile
+ .ConnectionStrings
+ .ConnectionStrings.["AdventureWorks"]
+ .ConnectionString <- gitHubActionSqlConnectionString
+ testConfigFile.Save()
+ gitHubActionSqlConnectionString
+ SqlConnectionStringBuilder connStr
+ testConnStr <- Some connStr
+ database <- Some connStr.InitialCatalog
+ conn <-
+ connStr.InitialCatalog <- ""
+ let cnx = new SqlConnection(string connStr)
+ cnx.Open()
+ Some cnx
+ )
+ }
- conn.Open()
+ stage "attach database to server" {
+ run (fun ctx ->
- do //attach
+ //attach
let dbIsMissing =
- let query = sprintf "SELECT COUNT(*) FROM sys.databases WHERE name = '%s'" database
- use cmd = new SqlCommand(query, conn)
+ let query = sprintf "SELECT COUNT(*) FROM sys.databases WHERE name = '%s'" database.Value
+ use cmd = new SqlCommand(query, conn.Value)
cmd.ExecuteScalar() = box 0
- if dbIsMissing
- then
+ if dbIsMissing then
let dataFileName = "AdventureWorks2012_Data"
//unzip
let sourceMdf = testsSourceRoot @@ (dataFileName + ".mdf")
@@ -189,32 +212,47 @@ Target.create "DeployTestDB" (fun _ ->
ZipFile.ExtractToDirectory(testsSourceRoot @@ (dataFileName + ".zip"), testsSourceRoot)
-
let dataPath =
- use cmd = new SqlCommand("SELECT SERVERPROPERTY('InstanceDefaultDataPath')", conn)
+ use cmd = new SqlCommand("SELECT SERVERPROPERTY('InstanceDefaultDataPath')", conn.Value)
cmd.ExecuteScalar() |> string
do
let destFileName = dataPath @@ Path.GetFileName(sourceMdf)
File.Copy(sourceMdf, destFileName, overwrite = true)
File.Delete( sourceMdf)
- use cmd = conn.CreateCommand(CommandText = sprintf "CREATE DATABASE [%s] ON ( FILENAME = N'%s' ) FOR ATTACH" database destFileName)
+ use cmd = conn.Value.CreateCommand(CommandText = sprintf "CREATE DATABASE [%s] ON ( FILENAME = N'%s' ) FOR ATTACH" database.Value destFileName)
cmd.ExecuteNonQuery() |> ignore
+ )
+ }
- do //create extra object to test corner case
+ //create extra object to test corner case
+ stage "patch adventure works" {
+ run (fun ctx ->
+ use _ = conn.Value
let script = File.ReadAllText(testsSourceRoot @@ "extensions.sql")
for batch in script.Split([|"GO";"go"|], StringSplitOptions.RemoveEmptyEntries) do
- use cmd = conn.CreateCommand(CommandText = batch)
+ try
+ use cmd = conn.Value.CreateCommand(CommandText = batch)
cmd.ExecuteNonQuery() |> ignore
+ with
+ e ->
+ let message = $"error while patching test db:\n{e.Message}\n{batch}"
+ printfn $"{message}"
+ raise (Exception(message, e))
+
+ )
+ }
+ runImmediate
+ }
)
let funBuildRestore stageName sln =
stage $"dotnet restore %s{stageName} '{sln}'" {
- run $"dotnet restore {sln}"
+ run $"dotnet restore {sln} --tl"
}
let funBuildRunMSBuild stageName sln =
let msbuild = $"\"{msBuildPaths [] }\""
stage $"run MsBuild %s{stageName}" {
- run $"{msbuild} {sln} -verbosity:quiet"
+ run $"{msbuild} {sln} -verbosity:quiet --tl"
}
Target.create "BuildTestProjects" (fun _ ->
diff --git a/global.json b/global.json
index fe6830e2..2fda2ee9 100644
--- a/global.json
+++ b/global.json
@@ -1 +1 @@
-{ "sdk": { "version": "7.0.400", "rollForward": "latestMinor" } }
\ No newline at end of file
+{ "sdk": { "version": "8.0.100", "rollForward": "latestMinor" } }
\ No newline at end of file
diff --git a/src/SqlClient.DesignTime/SqlClient.DesignTime.fsproj b/src/SqlClient.DesignTime/SqlClient.DesignTime.fsproj
index 415783d1..ffc2a73a 100644
--- a/src/SqlClient.DesignTime/SqlClient.DesignTime.fsproj
+++ b/src/SqlClient.DesignTime/SqlClient.DesignTime.fsproj
@@ -12,8 +12,9 @@
note: TypeProvider SDK comes with few warnings
FS0026: This rule will never be matched
FS3218: The argument names in the signature 'measure' and implementation 'm' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling.
+ FS3548: Pattern discard is not allowed for union case that takes no data.
-->
- $(WarningsNotAsErrors);FS0026;FS3218
+ $(WarningsNotAsErrors);FS0026;FS3218;FS3548
true
true
$(DefineConstants);DESIGNTIME_CODE_ONLY;WITH_LEGACY_NAMESPACE