Skip to content

Commit c6e48a4

Browse files
dotnet 8 sdk (#436)
1 parent 103fb5e commit c6e48a4

File tree

4 files changed

+72
-33
lines changed

4 files changed

+72
-33
lines changed

.github/workflows/dotnet-core.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ jobs:
1212
runs-on: windows-latest
1313

1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616
- name: Setup .NET Core
17-
uses: actions/setup-dotnet@v1
17+
uses: actions/setup-dotnet@v3
1818
with:
19-
dotnet-version: 7.0.400
19+
dotnet-version: 8.0.100
2020

2121
- name: Install SQL Server
2222
# reference @ https://github.com/Particular/install-sql-server-action
2323
uses: Particular/install-sql-server-action@v1.0.0
2424
with:
25-
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
26-
catalog: AdventureWroks
25+
connection-string-env-var: GITHUB_ACTION_SQL_SERVER_CONNECTION_STRING
26+
catalog: AdventureWorks2012
2727
extra-params: ""
2828
- name: Build
2929
env:

build/build.fs

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ let dotnetBuildDisableBinLog (args: DotNet.BuildOptions) =
141141
let dnDefault =
142142
dotnetBuildDisableBinLog
143143
>> DotNet.Options.withVerbosity (Some DotNet.Verbosity.Quiet)
144+
>> DotNet.Options.withCustomParams (Some "--tl")
144145

145146
Target.create "Build" (fun _ ->
146147
DotNet.build
@@ -154,33 +155,55 @@ open System.IO.Compression
154155
open Fake.DotNet.Testing
155156

156157
Target.create "DeployTestDB" (fun _ ->
157-
let testsSourceRoot = Path.GetFullPath(@"tests\SqlClient.Tests")
158-
let map = ExeConfigurationFileMap()
159-
map.ExeConfigFilename <- testsSourceRoot @@ "app.config"
160-
let connStr =
161-
let x =
162-
ConfigurationManager
163-
.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None)
158+
let testsSourceRoot = Path.GetFullPath(@"tests\SqlClient.Tests")
159+
let mutable database = None
160+
let mutable testConnStr = None
161+
let mutable conn = None
162+
163+
pipeline "DeployTestDB" {
164+
165+
stage "adjust config file connection strings" {
166+
run (fun ctx ->
167+
let map = ExeConfigurationFileMap()
168+
map.ExeConfigFilename <- testsSourceRoot @@ "app.config"
169+
let testConfigFile = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None)
170+
let connStr =
171+
let connStr =
172+
let gitHubActionSqlConnectionString = System.Environment.GetEnvironmentVariable "GITHUB_ACTION_SQL_SERVER_CONNECTION_STRING"
173+
if String.IsNullOrWhiteSpace gitHubActionSqlConnectionString then
174+
testConfigFile
164175
.ConnectionStrings
165176
.ConnectionStrings.["AdventureWorks"]
166177
.ConnectionString
167-
SqlConnectionStringBuilder(x)
168-
169-
let database = connStr.InitialCatalog
170-
use conn =
171-
connStr.InitialCatalog <- ""
172-
new SqlConnection(string connStr)
178+
else
179+
// we run under Github Actions, update the test config file connection string.
180+
testConfigFile
181+
.ConnectionStrings
182+
.ConnectionStrings.["AdventureWorks"]
183+
.ConnectionString <- gitHubActionSqlConnectionString
184+
testConfigFile.Save()
185+
gitHubActionSqlConnectionString
186+
SqlConnectionStringBuilder connStr
187+
testConnStr <- Some connStr
188+
database <- Some connStr.InitialCatalog
189+
conn <-
190+
connStr.InitialCatalog <- ""
191+
let cnx = new SqlConnection(string connStr)
192+
cnx.Open()
193+
Some cnx
194+
)
195+
}
173196

174-
conn.Open()
197+
stage "attach database to server" {
198+
run (fun ctx ->
175199

176-
do //attach
200+
//attach
177201
let dbIsMissing =
178-
let query = sprintf "SELECT COUNT(*) FROM sys.databases WHERE name = '%s'" database
179-
use cmd = new SqlCommand(query, conn)
202+
let query = sprintf "SELECT COUNT(*) FROM sys.databases WHERE name = '%s'" database.Value
203+
use cmd = new SqlCommand(query, conn.Value)
180204
cmd.ExecuteScalar() = box 0
181205

182-
if dbIsMissing
183-
then
206+
if dbIsMissing then
184207
let dataFileName = "AdventureWorks2012_Data"
185208
//unzip
186209
let sourceMdf = testsSourceRoot @@ (dataFileName + ".mdf")
@@ -189,32 +212,47 @@ Target.create "DeployTestDB" (fun _ ->
189212

190213
ZipFile.ExtractToDirectory(testsSourceRoot @@ (dataFileName + ".zip"), testsSourceRoot)
191214

192-
193215
let dataPath =
194-
use cmd = new SqlCommand("SELECT SERVERPROPERTY('InstanceDefaultDataPath')", conn)
216+
use cmd = new SqlCommand("SELECT SERVERPROPERTY('InstanceDefaultDataPath')", conn.Value)
195217
cmd.ExecuteScalar() |> string
196218
do
197219
let destFileName = dataPath @@ Path.GetFileName(sourceMdf)
198220
File.Copy(sourceMdf, destFileName, overwrite = true)
199221
File.Delete( sourceMdf)
200-
use cmd = conn.CreateCommand(CommandText = sprintf "CREATE DATABASE [%s] ON ( FILENAME = N'%s' ) FOR ATTACH" database destFileName)
222+
use cmd = conn.Value.CreateCommand(CommandText = sprintf "CREATE DATABASE [%s] ON ( FILENAME = N'%s' ) FOR ATTACH" database.Value destFileName)
201223
cmd.ExecuteNonQuery() |> ignore
224+
)
225+
}
202226

203-
do //create extra object to test corner case
227+
//create extra object to test corner case
228+
stage "patch adventure works" {
229+
run (fun ctx ->
230+
use _ = conn.Value
204231
let script = File.ReadAllText(testsSourceRoot @@ "extensions.sql")
205232
for batch in script.Split([|"GO";"go"|], StringSplitOptions.RemoveEmptyEntries) do
206-
use cmd = conn.CreateCommand(CommandText = batch)
233+
try
234+
use cmd = conn.Value.CreateCommand(CommandText = batch)
207235
cmd.ExecuteNonQuery() |> ignore
236+
with
237+
e ->
238+
let message = $"error while patching test db:\n{e.Message}\n{batch}"
239+
printfn $"{message}"
240+
raise (Exception(message, e))
241+
242+
)
243+
}
244+
runImmediate
245+
}
208246
)
209247

210248
let funBuildRestore stageName sln =
211249
stage $"dotnet restore %s{stageName} '{sln}'" {
212-
run $"dotnet restore {sln}"
250+
run $"dotnet restore {sln} --tl"
213251
}
214252
let funBuildRunMSBuild stageName sln =
215253
let msbuild = $"\"{msBuildPaths [] }\""
216254
stage $"run MsBuild %s{stageName}" {
217-
run $"{msbuild} {sln} -verbosity:quiet"
255+
run $"{msbuild} {sln} -verbosity:quiet --tl"
218256
}
219257

220258
Target.create "BuildTestProjects" (fun _ ->

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "sdk": { "version": "7.0.400", "rollForward": "latestMinor" } }
1+
{ "sdk": { "version": "8.0.100", "rollForward": "latestMinor" } }

src/SqlClient.DesignTime/SqlClient.DesignTime.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
note: TypeProvider SDK comes with few warnings
1313
FS0026: This rule will never be matched
1414
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.
15+
FS3548: Pattern discard is not allowed for union case that takes no data.
1516
-->
16-
<WarningsNotAsErrors>$(WarningsNotAsErrors);FS0026;FS3218</WarningsNotAsErrors>
17+
<WarningsNotAsErrors>$(WarningsNotAsErrors);FS0026;FS3218;FS3548</WarningsNotAsErrors>
1718
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
1819
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
1920
<DefineConstants>$(DefineConstants);DESIGNTIME_CODE_ONLY;WITH_LEGACY_NAMESPACE</DefineConstants>

0 commit comments

Comments
 (0)