Skip to content

Commit aeba8f7

Browse files
adjust some build steps with msbuild to see if it works same on CI and locally
* use fsharp.core 5 in unit tests * lib test project to netstandard rather than netcore * net40 program does a bit more
1 parent 97187ed commit aeba8f7

File tree

10 files changed

+743
-634
lines changed

10 files changed

+743
-634
lines changed

build.fsx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,30 @@ let slnPath = "SqlClient.sln"
7575
let testProjectsSlnPath = "TestProjects.sln"
7676
let testSlnPath = "Tests.sln"
7777
let testProjectPath = "tests/SqlClient.Tests/SqlClient.Tests.fsproj"
78+
let runMsBuild project =
79+
Fake.DotNet.MSBuild.build
80+
(fun args ->
81+
let toolPath =
82+
[
83+
@"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"
84+
@"C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\current\Bin"
85+
@"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\current\Bin"
86+
@"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\current\Bin"
87+
args.ToolPath
88+
]
89+
|> List.map (fun p -> Path.Combine(p, "MSBuild.exe"))
90+
|> List.find File.Exists
91+
let properties =
92+
[ yield "Configuration", "Release"
93+
for n,v in args.Properties do
94+
if n <> "Configuration" then
95+
yield n,v
96+
]
97+
{ args
98+
with ToolPath = toolPath
99+
Properties = properties
100+
} ) project
101+
78102

79103
Target.create "Clean" (fun _ ->
80104
Shell.cleanDirs ["bin"; "temp"]
@@ -165,21 +189,17 @@ Target.create "DeployTestDB" (fun _ ->
165189
)
166190

167191
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
192+
DotNet.restore dnDefault testProjectsSlnPath
193+
runMsBuild testProjectsSlnPath
176194
)
177195

178196
// --------------------------------------------------------------------------------------
179197
// Run the unit tests
180198
Target.create "RunTests" (fun _ ->
181199
// if we don't compile the targets sequentially, we get an error with the generated types:
182200
// 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.
201+
DotNet.restore dnDefault testSlnPath
202+
runMsBuild testSlnPath
183203
try
184204
DotNet.test (fun args -> { args with Framework = Some "net461"; Common = args.Common |> dnDefault }) testSlnPath
185205
DotNet.test (fun args -> { args with Framework = Some "netcoreapp2.0"; Common = args.Common |> dnDefault }) testProjectPath

paket.dependencies

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ group Build
2121

2222
group DesignTime
2323
source https://www.nuget.org/api/v2/
24-
framework: >= net461,netstandard20
24+
framework: >= net461, >= netstandard20
2525
storage: none
2626

2727
nuget System.Configuration.ConfigurationManager
@@ -34,10 +34,10 @@ group DesignTime
3434

3535
group Test
3636
source https://www.nuget.org/api/v2/
37-
framework: net461, netcoreapp2.0
37+
framework: >= net461, >= netcoreapp2.0
3838
storage: none
3939

40-
nuget FSharp.Core = 4.5.2 redirects:force
40+
nuget FSharp.Core = 5.0.0 redirects:force
4141
nuget System.Data.SqlClient
4242
nuget System.Configuration.ConfigurationManager
4343

@@ -55,7 +55,7 @@ group Net40
5555

5656
group TestProjects
5757
source https://www.nuget.org/api/v2/
58-
framework: >= net40, netcoreapp2.0, netstandard2.0
58+
framework: >= net40, >= netcoreapp2.0, >= netstandard2.0
5959
storage: none
6060

6161
nuget FSharp.Core = 4.3.4
@@ -65,7 +65,7 @@ group TestProjects
6565

6666
group Samples
6767
source https://www.nuget.org/api/v2/
68-
framework: >= net40
68+
framework: >= net40, >= netcoreapp2.0, >= netstandard2.0
6969
redirects: on
7070

7171
nuget FSharp.Core = 4.5.2 redirects: force

paket.lock

Lines changed: 691 additions & 607 deletions
Large diffs are not rendered by default.

src/SqlClient.TestProjects/Lib/Lib.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="..\..\..\fsc.props" />
44
<Import Project="..\..\..\netfx.props" />
55
<PropertyGroup>
6-
<TargetFrameworks>net471;netcoreapp2.0</TargetFrameworks>
6+
<TargetFrameworks>net471;netstandard2.0</TargetFrameworks>
77
<AssemblyName>Lib</AssemblyName>
88
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
99
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -19,7 +19,7 @@
1919
</ItemGroup>
2020
<ItemGroup>
2121
<Reference Include="netstandard" />
22-
<Reference Condition="'$(TargetFramework)' == 'netcoreapp2.0'" Include="FSharp.Data.SqlClient">
22+
<Reference Condition="'$(TargetFramework)' == 'netstandard2.0'" Include="FSharp.Data.SqlClient">
2323
<HintPath>..\..\..\bin\netstandard2.0\FSharp.Data.SqlClient.dll</HintPath>
2424
</Reference>
2525
<Reference Condition="'$(TargetFramework)' == 'net471'" Include="FSharp.Data.SqlClient">

src/SqlClient.TestProjects/Lib/Library1.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module DataAccess
2-
2+
open FSharp.Data
33
open FSharp.Data.SqlClient
44

55
type Get42 = SqlCommandProvider<"SELECT 42", "name=AdventureWorks", SingleRow = true>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
open FSharp.Data.SqlClient
2+
open FSharp.Data
23

34
[<Literal>]
45
let connectionString = "Data Source=localhost;Initial Catalog=AdventureWorks2012;Integrated Security=True"
56

7+
type SingleColumnSelect = SqlEnumProvider<"SELECT Name FROM Purchasing.ShipMethod", connectionString>
8+
type TinyIntEnum = SqlEnumProvider<"SELECT * FROM (VALUES(('One'), CAST(1 AS tinyint)), ('Two', CAST(2 AS tinyint))) AS T(Tag, Value)", connectionString, Kind = SqlEnumKind.CLI>
9+
type CurrencyCodeUOM =
10+
SqlEnumProvider<"
11+
SELECT CurrencyCode
12+
FROM Sales.Currency
13+
WHERE CurrencyCode IN ('USD', 'EUR', 'GBP')
14+
", connectionString, Kind = SqlEnumKind.UnitsOfMeasure>
15+
616
[<EntryPoint>]
717
let main _ =
818
let get42 = new SqlCommandProvider<"SELECT 42", connectionString>(connectionString)
919
get42.Execute() |> Seq.toArray |> printfn "%A"
20+
21+
printfn "SqlEnum default test: %A" SingleColumnSelect.``CARGO TRANSPORT 5``
22+
printfn "SqlEnum CLI enum test: %A" TinyIntEnum.One
23+
printfn "SqlEnum UOM test: %A" 1m<CurrencyCodeUOM.USD>
1024
0

src/SqlClient.TestProjects/SqlClient.Tests.NetCoreApp/Program.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
open FSharp.Data.SqlClient
2+
open FSharp.Data
23

34
[<Literal>]
45
let Cnx = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True"

tests/SqlClient.DesignTime.Tests/app.config

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
<assemblyIdentity name="xunit" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
1717
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.9.2.1705" />
1818
</dependentAssembly>
19-
<dependentAssembly>
20-
<Paket>True</Paket>
21-
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
22-
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.5.0.0" />
23-
</dependentAssembly>
2419
</assemblyBinding></runtime>
2520
<!--<connectionStrings configSource="connectionStrings.Azure.config"/>-->
2621
<connectionStrings>

tests/SqlClient.SqlServerTypes.Tests/App.config

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
<assemblyIdentity name="xunit" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
1111
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.9.2.1705" />
1212
</dependentAssembly>
13-
<dependentAssembly>
14-
<Paket>True</Paket>
15-
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
16-
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.5.0.0" />
17-
</dependentAssembly>
1813
<dependentAssembly>
1914
<Paket>True</Paket>
2015
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />

tests/SqlClient.Tests/app.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
<dependentAssembly>
1313
<Paket>True</Paket>
1414
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
15-
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.5.0.0" />
15+
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.0.0.0" />
1616
</dependentAssembly>
1717
</assemblyBinding></runtime></configuration>

0 commit comments

Comments
 (0)