Skip to content

Commit a597ce3

Browse files
committed
Split the C# code/project changes out from the pipeline changes.
1 parent 2655083 commit a597ce3

22 files changed

+854
-108
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ dotnet_diagnostic.xUnit1031.severity=none
159159
dotnet_diagnostic.xUnit1030.severity=none
160160

161161
# Xml files
162-
[*.{xml,csproj,stylecop,resx,ruleset,props,targets,config,nuspec}]
162+
[*.{xml,slnx,proj,csproj,stylecop,resx,ruleset,props,targets,config,nuspec}]
163163
indent_size = 2
164164

165165
# Shell scripts

BUILDGUIDE.md

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,46 @@ Once the environment is setup properly, execute the desired set of commands belo
1616

1717
### Targets
1818

19+
The following build targets are defined in `build.proj`:
20+
1921
|Target|Description|
2022
|-|-|
2123
|`BuildAllConfigurations`|Default target. Builds the .NET Framework and .NET drivers for all target frameworks and operating systems.|
24+
|`BuildAbstractionsPackage`|Restore, build, and pack the Abstractions package, publishing the resulting NuGet into `packages/`.|
2225
|`BuildNetCore`|Builds the .NET driver for all target frameworks.|
2326
|`BuildNetCoreAllOS`|Builds the .NET driver for all target frameworks and operating systems.|
2427
|`BuildNetFx`|Builds the .NET Framework driver for all target frameworks.|
2528
|`BuildTestsNetCore`|Builds tests for the .NET driver.|
2629
|`BuildTestsNetFx`|Builds tests for the .NET Framework driver.|
27-
|`Clean`|Cleans generated files.|
28-
|`Restore`|Restores Nuget packages.|
30+
|`Clean`|Cleans all generated files.|
31+
|`Restore`|Restores NuGet packages.|
2932
|`RunTests`|Runs the unit, functional, and manual tests for the .NET Framework and .NET drivers|
3033
|`RunUnitTests`|Runs just the unit tests for the .NET Framework and .NET drivers|
3134
|`RunFunctionalTests`|Runs just the functional tests for the .NET Framework and .NET drivers|
3235
|`RunManualTests`|Runs just the manual tests for the .NET Framework and .NET drivers|
3336
|`BuildAkv`|Builds the Azure Key Vault Provider package for all supported platforms.|
3437

35-
3638
### Parameters
39+
40+
The following parameters may be defined as MSBuild properties to configure the
41+
build:
42+
3743
|Name|Supported Values|Default|Description|
3844
|-|-|-|-|
3945
|`Configuration`|`Debug`, `Release`|`Debug`|Sets the release configuration.|
40-
|`BuildNetFx`|`true`, `false`|`true` (Windows), `false` (other)|If false, skips building the .NET Framework driver on Windows.|
4146
|`OSGroup`|`Unix`, `Windows_NT`, `AnyOS`|typically defaults to the client system's OS, unless using `BuildAllConfigurations` or an `AnyOS` specific target|The operating system to target.|
4247
|`Platform`|`AnyCPU`, `x86`, `x64`, `ARM`, `ARM64`|`AnyCPU`|May only be set when using package reference type or running tests.|
4348
|`TestSet`|`1`, `2`, `3`, `AE`|all|Build or run a subset of the manual tests. Omit (default) to target all tests.|
4449
|`DotnetPath`|Absolute file path to an installed `dotnet` version.|The system default specified by the path variable|Set to run tests using a specific dotnet version (e.g. C:\net6-win-x86\)|
4550
|`TF`|`net8.0`, `net462`, `net47`, `net471`, `net472`, `net48`, `net481`|`net8.0` in netcore, `net462` in netfx|Sets the target framework when building or running tests. Not applicable when building the drivers.|
4651
|`ResultsDirectory`|An absolute file path|./TestResults relative to current directory|Specifies where to write test results.|
4752

48-
4953
## Example Workflows using MSBuild (Recommended)
54+
5055
Using the default configuration and running all tests:
5156

5257
```bash
58+
msbuild -t:BuildAbstractionsPackage
5359
msbuild
5460
msbuild -t:BuildTestsNetFx -p:TF=net462
5561
msbuild -t:BuildTestsNetCore
@@ -59,28 +65,31 @@ msbuild -t:RunTests
5965
Using the Release configuration:
6066

6167
```bash
62-
msbuild -p:configuration=Release
63-
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:configuration=Release
64-
msbuild -t:BuildTestsNetCore -p:configuration=Release
65-
msbuild -t:RunTests -p:configuration=Release
68+
msbuild -t:BuildAbstractionsPackage -p:Configuration=Release
69+
msbuild -p:Configuration=Release
70+
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:Configuration=Release
71+
msbuild -t:BuildTestsNetCore -p:Configuration=Release
72+
msbuild -t:RunTests -p:Configuration=Release
6673
```
6774

6875
Running only the unit tests:
6976

7077
```bash
78+
msbuild -t:BuildAbstractionsPackage
7179
msbuild
7280
msbuild -t:BuildTestsNetFx -p:TF=net462
7381
msbuild -t:BuildTestsNetCore
7482
msbuild -t:RunUnitTests
7583
```
7684

77-
Using a specific dotnet version/architecture:
85+
Using a specific .NET runtime to run tests:
7886

7987
```bash
80-
msbuild -p:configuration=Release
81-
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:configuration=Release
82-
msbuild -t:BuildTestsNetCore -p:configuration=Release
83-
msbuild -t:RunTests -p:configuration=Release -p:DotnetPath=C:\net8-win-x86\
88+
msbuild -t:BuildAbstractionsPackage
89+
msbuild
90+
msbuild -t:BuildTestsNetFx -p:TF=net462
91+
msbuild -t:BuildTestsNetCore
92+
msbuild -t:RunTests -p:DotnetPath=C:\net8-win-x86\
8493
```
8594

8695
### Running Manual Tests
@@ -119,15 +128,13 @@ Manual Tests require the below setup to run:
119128
|IsManagedInstance | (Optional) When set to `true` **TVP** related tests will use on non-Azure bs files to compare test results. this is needed when testing against Managed Instances or TVP Tests will fail on Test set 3. The default value is `false`. |
120129
|PowerShellPath | The full path to PowerShell.exe. This is not required if the path is present in the PATH environment variable. | `D:\\escaped\\absolute\\path\\to\\PowerShell.exe` |
121130

122-
123131
## Example workflows using the Dotnet SDK
124132

125-
#### Run Functional Tests
133+
### Run Functional Tests
126134

127135
- Windows (`netfx x86`):
128136

129137
```bash
130-
msbuild
131138
dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.SqlClient.Tests.csproj" -p:Platform="x86" -p:Configuration="Release" -p:TestTargetOS="Windowsnetfx" --no-build -v n --filter "category!=nonnetfxtests&category!=failing&category!=nonwindowstests"
132139
```
133140

@@ -152,7 +159,8 @@ dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.S
152159
```bash
153160
dotnet test "src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj" -p:Platform="AnyCPU" -p:Configuration="Release" -p:TestTargetOS="Unixnetcoreapp" --no-build -v n --filter "category!=nonnetcoreapptests&category!=failing&category!=nonlinuxtests&category!=nonuaptests"
154161
```
155-
#### Run Manual Tests
162+
163+
### Run Manual Tests
156164

157165
- Windows (`netfx x86`):
158166

@@ -194,35 +202,40 @@ dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlCl
194202

195203
Tests can be built and run with custom "Reference Type" property that enables different styles of testing:
196204

197-
- "Project" => Build and run tests with Microsoft.Data.SqlClient as Project Reference
198-
- "Package" => Build and run tests with Microsoft.Data.SqlClient as Package Reference with configured "TestMicrosoftDataSqlClientVersion" in "Versions.props" file.
205+
- "Project" => Build and run tests with Microsoft.Data.SqlClient as a Project Reference
206+
- "Package" => Build and run tests with Microsoft.Data.SqlClient as a Package Reference with configured "TestMicrosoftDataSqlClientVersion" in "Versions.props" file.
199207

200208
> ************** IMPORTANT NOTE BEFORE PROCEEDING WITH "PACKAGE" REFERENCE TYPE ***************
201209
> CREATE A NUGET PACKAGE WITH BELOW COMMAND AND ADD TO LOCAL FOLDER + UPDATE NUGET CONFIG FILE TO READ FROM THAT LOCATION
202210
>
203211
> ```bash
204-
> msbuild -p:configuration=Release
212+
> msbuild -t:BuildAbstractionsPackage -p:Configuration=Release
213+
> msbuild -p:Configuration=Release
205214
> ```
206215
207216
A non-AnyCPU platform reference can only be used with package reference type. Otherwise, the specified platform will be replaced with AnyCPU in the build process.
208217
209218
### Building Tests with Reference Type
210219
211-
For .NET, all 4 reference types are supported:
220+
For .NET:
212221
213222
```bash
223+
# Project is the default reference type. The below commands are equivalent:
224+
msbuild -t:BuildTestsNetCore
214225
msbuild -t:BuildTestsNetCore -p:ReferenceType=Project
215-
# Default setting uses Project Reference.
216226
227+
# Package reference type:
217228
msbuild -t:BuildTestsNetCore -p:ReferenceType=Package
218229
```
219230
220-
For .NET Framework, below reference types are supported:
231+
For .NET Framework:
221232

222233
```bash
234+
# Project is the default reference type. The below commands are equivalent:
235+
msbuild -t:BuildTestsNetFx -p:TF=net462
223236
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:ReferenceType=Project
224-
# Default setting uses Project Reference.
225237

238+
# Package reference type:
226239
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:ReferenceType=Package
227240
```
228241

@@ -241,26 +254,25 @@ Tests can be built and run with custom Target Frameworks. See the below examples
241254
### Building Tests with custom target framework
242255

243256
```bash
244-
msbuild -t:BuildTestsNetFx -p:TF=net462
245257
# Build the tests for custom .NET Framework target
258+
msbuild -t:BuildTestsNetFx -p:TF=net462
246259
```
247260

248261
```bash
249-
msbuild -t:BuildTestsNetCore -p:TF=net8.0
250262
# Build the tests for custom .NET target
263+
msbuild -t:BuildTestsNetCore -p:TF=net8.0
251264
```
252265

253266
### Running Tests with custom target framework (traditional)
254267

255268
```bash
269+
# Run tests with custom .NET Framework target
256270
dotnet test -p:TargetNetFxVersion=net462 ...
257-
# Use above property to run Functional Tests with custom .NET Framework target
258271

272+
# Run tests with custom .NET target
259273
dotnet test -p:TargetNetCoreVersion=net8.0 ...
260-
# Use above property to run Functional Tests with custom .NET target
261274
```
262275

263-
264276
## Using Managed SNI on Windows
265277

266278
Managed SNI can be enabled on Windows by enabling the below AppContext switch:
@@ -285,20 +297,6 @@ When connecting to a server, if a protocol lower than TLS 1.2 is negotiated, a s
285297

286298
`Switch.Microsoft.Data.SqlClient.SuppressInsecureTLSWarning`
287299

288-
### Troubleshooting Docker issues
289-
290-
There may be times where connection cannot be made to SQL Server, we found below ideas helpful:
291-
292-
- Clear Docker images to create clean image from time-to-time, and clear docker cache if needed by running `docker system prune` in Command Prompt.
293-
294-
- If you face `Microsoft.Data.SqlClient.SNI.dll not found` errors when debugging, try updating the below properties in the netcore\Microsoft.Data.SqlClient.csproj file and try again:
295-
296-
```xml
297-
<OSGroup>Unix</OSGroup>
298-
<TargetsWindows>false</TargetsWindows>
299-
<TargetsUnix>true</TargetsUnix>
300-
```
301-
302300
## Collecting Code Coverage
303301

304302
### Using VSTest

NuGet.config

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
4+
5+
<!-- Clear all inherited feeds. -->
46
<clear />
5-
<add key="sqlclient" value="https://sqlclientdrivers.pkgs.visualstudio.com/public/_packaging/sqlclient/nuget/v3/index.json" />
7+
8+
<!--
9+
We do not use the public nuget.org feed. Instead, we use a governed
10+
feed maintained by our SqlClientDrivers ADO organization. Packages must
11+
be individually vetted and added to this feed manually before they will
12+
be available for consumption by our builds.
13+
14+
https://sqlclientdrivers.visualstudio.com/public/_artifacts/feed/sqlclient
15+
-->
16+
<add key="governed" value="https://sqlclientdrivers.pkgs.visualstudio.com/public/_packaging/sqlclient/nuget/v3/index.json" />
617
</packageSources>
18+
719
<auditSources>
20+
21+
<!-- Clear all inherited audit sources. -->
822
<clear />
23+
24+
<!--
25+
There is no governed ADO feed for auditing, so we use the public
26+
nuget.org source.
27+
-->
928
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
1029
</auditSources>
1130
</configuration>

0 commit comments

Comments
 (0)