Skip to content

Commit 327ea6d

Browse files
committed
Merge branch 'main' into dev/paul/duplicate-runs
2 parents d85a1f3 + 356ef6c commit 327ea6d

208 files changed

Lines changed: 9989 additions & 4326 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

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

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

168168
# Shell scripts

.github/workflows/codeql.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ name: "CodeQL Advanced"
1313

1414
on:
1515
push:
16-
branches: [ "main" ]
16+
branches: [ "main", "feat/*", "dev/**/*" ]
1717
pull_request:
18-
branches: [ "main" ]
18+
branches: [ "main", "feat/*", "dev/**/*" ]
1919
schedule:
2020
- cron: '33 23 * * 6'
2121

2222
jobs:
2323
analyze:
24+
if: github.event.repository.fork == false
2425
name: Analyze (${{ matrix.language }})
2526
# Runner size impacts CodeQL analysis time. To learn more, please see:
2627
# - https://gh.io/recommended-hardware-resources-for-running-codeql
@@ -84,9 +85,22 @@ jobs:
8485
- name: Run manual build steps
8586
if: matrix.build-mode == 'manual'
8687
shell: bash
88+
# TODO(https://sqlclientdrivers.visualstudio.com/ADO.Net/_workitems/edit/41729):
89+
# For some reason, the StressTests projects fail to restore in this
90+
# environment, so we skip them by explicitly building all of the other
91+
# projects instead of the main solution file.
8792
run: |
88-
mkdir packages
89-
dotnet build src/
93+
dotnet build src/Microsoft.SqlServer.Server
94+
dotnet build src/Microsoft.Data.SqlClient/netcore/ref
95+
dotnet build src/Microsoft.Data.SqlClient/netcore/src
96+
dotnet build src/Microsoft.Data.SqlClient/netfx/ref
97+
dotnet build src/Microsoft.Data.SqlClient/netfx/src
98+
dotnet build src/Microsoft.Data.SqlClient/src
99+
dotnet build src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider
100+
dotnet build src/Microsoft.Data.SqlClient/tests/UnitTests
101+
dotnet build src/Microsoft.Data.SqlClient/tests/FunctionalTests
102+
dotnet build src/Microsoft.Data.SqlClient/tests/ManualTests
103+
dotnet build src/Microsoft.Data.SqlClient/tests/PerformanceTests
90104
91105
- name: Perform CodeQL Analysis
92106
uses: github/codeql-action/analyze@v4

.github/workflows/stale.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ permissions:
1414
jobs:
1515
close-stale:
1616
runs-on: ubuntu-latest
17+
if: github.event.repository.fork == false
1718
name: Close stale Issues and PRs
1819

1920
steps:

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,10 @@ PublishScripts/
193193
*.nupkg
194194
# NuGet Symbol Packages
195195
*.snupkg
196-
# The packages folder can be ignored because of Package Restore
196+
# Most of the packages folder can be ignored.
197197
**/[Pp]ackages/*
198-
# except build/, which is used as an MSBuild target.
199-
!**/[Pp]ackages/build/
200-
# Uncomment if necessary however generally it will be regenerated when needed
201-
#!**/[Pp]ackages/repositories.config
198+
!**/[Pp]ackages/.gitkeep
199+
202200
# NuGet v3's project.json files produces more ignorable files
203201
*.nuget.props
204202
*.nuget.targets

BUILDGUIDE.md

Lines changed: 66 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,46 @@ Once the environment is setup properly, execute the desired set of commands belo
2525

2626
### Targets
2727

28+
The following build targets are defined in `build.proj`:
29+
2830
|Target|Description|
2931
|-|-|
32+
|`BuildAbstractions`|Restore, build, and pack the Abstractions package, publishing the resulting NuGet into `packages/`.|
3033
|`BuildAllConfigurations`|Default target. Builds the .NET Framework and .NET drivers for all target frameworks and operating systems.|
34+
|`BuildAzure`|Restore, build, and pack the Azure package, publishing the resulting NuGet into `packages/`.|
3135
|`BuildNetCore`|Builds the .NET driver for all target frameworks.|
3236
|`BuildNetCoreAllOS`|Builds the .NET driver for all target frameworks and operating systems.|
3337
|`BuildNetFx`|Builds the .NET Framework driver for all target frameworks.|
3438
|`BuildTestsNetCore`|Builds tests for the .NET driver.|
3539
|`BuildTestsNetFx`|Builds tests for the .NET Framework driver.|
36-
|`Clean`|Cleans generated files.|
37-
|`Restore`|Restores Nuget packages.|
40+
|`Clean`|Cleans all generated files.|
41+
|`Restore`|Restores NuGet packages.|
3842
|`RunTests`|Runs the unit, functional, and manual tests for the .NET Framework and .NET drivers|
3943
|`RunUnitTests`|Runs just the unit tests for the .NET Framework and .NET drivers|
4044
|`RunFunctionalTests`|Runs just the functional tests for the .NET Framework and .NET drivers|
4145
|`RunManualTests`|Runs just the manual tests for the .NET Framework and .NET drivers|
4246
|`BuildAkv`|Builds the Azure Key Vault Provider package for all supported platforms.|
4347

44-
4548
### Parameters
49+
50+
The following parameters may be defined as MSBuild properties to configure the
51+
build:
52+
4653
|Name|Supported Values|Default|Description|
4754
|-|-|-|-|
4855
|`Configuration`|`Debug`, `Release`|`Debug`|Sets the release configuration.|
49-
|`BuildNetFx`|`true`, `false`|`true` (Windows), `false` (other)|If false, skips building the .NET Framework driver on Windows.|
5056
|`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.|
5157
|`Platform`|`AnyCPU`, `x86`, `x64`, `ARM`, `ARM64`|`AnyCPU`|May only be set when using package reference type or running tests.|
5258
|`TestSet`|`1`, `2`, `3`, `AE`|all|Build or run a subset of the manual tests. Omit (default) to target all tests.|
5359
|`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\)|
5460
|`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.|
5561
|`ResultsDirectory`|An absolute file path|./TestResults relative to current directory|Specifies where to write test results.|
5662

57-
5863
## Example Workflows using MSBuild (Recommended)
64+
5965
Using the default configuration and running all tests:
6066

6167
```bash
62-
msbuild
6368
msbuild -t:BuildTestsNetFx -p:TF=net462
6469
msbuild -t:BuildTestsNetCore
6570
msbuild -t:RunTests
@@ -68,28 +73,25 @@ msbuild -t:RunTests
6873
Using the Release configuration:
6974

7075
```bash
71-
msbuild -p:configuration=Release
72-
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:configuration=Release
73-
msbuild -t:BuildTestsNetCore -p:configuration=Release
74-
msbuild -t:RunTests -p:configuration=Release
76+
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:Configuration=Release
77+
msbuild -t:BuildTestsNetCore -p:Configuration=Release
78+
msbuild -t:RunTests -p:Configuration=Release
7579
```
7680

7781
Running only the unit tests:
7882

7983
```bash
80-
msbuild
8184
msbuild -t:BuildTestsNetFx -p:TF=net462
8285
msbuild -t:BuildTestsNetCore
8386
msbuild -t:RunUnitTests
8487
```
8588

86-
Using a specific dotnet version/architecture:
89+
Using a specific .NET runtime to run tests:
8790

8891
```bash
89-
msbuild -p:configuration=Release
90-
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:configuration=Release
91-
msbuild -t:BuildTestsNetCore -p:configuration=Release
92-
msbuild -t:RunTests -p:configuration=Release -p:DotnetPath=C:\net8-win-x86\
92+
msbuild -t:BuildTestsNetFx -p:TF=net462
93+
msbuild -t:BuildTestsNetCore
94+
msbuild -t:RunTests -p:DotnetPath=C:\net8-win-x86\
9395
```
9496

9597
### Running Manual Tests
@@ -117,7 +119,7 @@ Manual Tests require the below setup to run:
117119
|AADSecurePrincipalSecret | (Optional) A Secret defined for a registered application which has been granted permission to the database defined in the AADPasswordConnectionString. | {Secret} |
118120
|AzureKeyVaultURL | (Optional) Azure Key Vault Identifier URL | `https://{keyvaultname}.vault.azure.net/` |
119121
|AzureKeyVaultTenantId | (Optional) The Azure Active Directory tenant (directory) Id of the service principal. | _{Tenant ID of Active Directory}_ |
120-
|SupportsIntegratedSecurity | (Optional) Whether or not the USER running tests has integrated security access to the target SQL Server.| `true` OR `false`|
122+
|SupportsIntegratedSecurity | (Optional) Whether or not the USER running tests has integrated security access to the target SQL Server.| `true` OR `false`|
121123
|LocalDbAppName | (Optional) If Local Db Testing is supported, this property configures the name of Local DB App instance available in client environment. Empty string value disables Local Db testing. | Name of Local Db App to connect to.|
122124
|LocalDbSharedInstanceName | (Optional) If LocalDB testing is supported and the instance is shared, this property configures the name of the shared instance of LocalDB to connect to. | Name of shared instance of LocalDB. |
123125
|FileStreamDirectory | (Optional) If File Stream is enabled on SQL Server, pass local directory path to be used for setting up File Stream enabled database. | `D:\\escaped\\absolute\\path\\to\\directory\\` |
@@ -128,15 +130,13 @@ Manual Tests require the below setup to run:
128130
|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`. |
129131
|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` |
130132

131-
132133
## Example workflows using the Dotnet SDK
133134

134-
#### Run Functional Tests
135+
### Run Functional Tests
135136

136137
- Windows (`netfx x86`):
137138

138139
```bash
139-
msbuild
140140
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"
141141
```
142142

@@ -147,11 +147,11 @@ dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.S
147147
```
148148

149149
- AnyCPU:
150-
150+
151151
Project reference only builds Driver with `AnyCPU` platform, and underlying process decides to run the tests with a compatible architecture (x64, x86, ARM64).
152152

153153
Windows (`netcoreapp`):
154-
154+
155155
```bash
156156
dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.SqlClient.Tests.csproj" -p:Platform="AnyCPU" -p:Configuration="Release" -p:TestTargetOS="Windowsnetcoreapp" --no-build -v n --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests"
157157
```
@@ -161,7 +161,8 @@ dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.S
161161
```bash
162162
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"
163163
```
164-
#### Run Manual Tests
164+
165+
### Run Manual Tests
165166

166167
- Windows (`netfx x86`):
167168

@@ -199,39 +200,61 @@ dotnet test "src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlCl
199200
dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Platform="AnyCPU" -p:Configuration="Release" -p:TestTargetOS="Windowsnetcoreapp" --no-build -v n --filter "FullyQualifiedName=Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted.CspProviderExt.TestKeysFromCertificatesCreatedWithMultipleCryptoProviders"
200201
```
201202

202-
## Testing with Custom ReferenceType
203+
## Testing with Package References
203204

204-
Tests can be built and run with custom "Reference Type" property that enables different styles of testing:
205+
The MDS driver consists of several components, each of which produces its own
206+
NuGet package. During development, components reference each other via
207+
`<ProjectReference>` properties by default. This means that building
208+
and testing one component will implicitly build its project referenced
209+
dependencies.
205210

206-
- "Project" => Build and run tests with Microsoft.Data.SqlClient as Project Reference
207-
- "Package" => Build and run tests with Microsoft.Data.SqlClient as Package Reference with configured "TestMicrosoftDataSqlClientVersion" in "Versions.props" file.
211+
Alternatively, the `ReferenceType` build property may be specified with a value
212+
of `Package`. This will change inter-component dependencies to use
213+
`<PackageReference>` dependencies, and require that dependent components be
214+
built and packaged before building the depending component. This will generate NuGet
215+
packages in the root packages/ directory, and will be automatically searched by NuGet
216+
(see our root `NuGet.config`).
208217

209-
> ************** IMPORTANT NOTE BEFORE PROCEEDING WITH "PACKAGE" REFERENCE TYPE ***************
210-
> CREATE A NUGET PACKAGE WITH BELOW COMMAND AND ADD TO LOCAL FOLDER + UPDATE NUGET CONFIG FILE TO READ FROM THAT LOCATION
211-
>
212-
> ```bash
213-
> msbuild -p:configuration=Release
214-
> ```
218+
Then, you can specify `Package` references be used, for example:
219+
220+
```bash
221+
dotnet build -t:BuildAbstractions
222+
dotnet build -t:BuildAzure -p:ReferenceType=Package
223+
dotnet build -t:BuildAll -p:ReferenceType=Package
224+
dotnet build -t:BuildAKVNetCore -p:ReferenceType=Package
225+
dotnet build -t:GenerateMdsPackage
226+
dotnet build -t:GenerateAkvPackage
227+
dotnet build -t:BuildTestsNetCore -p:ReferenceType=Package
228+
```
215229

216-
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.
230+
The above will build the MDS and AKV components, place their NuGet packages into
231+
the `packages/` directory, and then build the tests using those packages.
217232

218-
### Building Tests with Reference Type
233+
A non-AnyCPU platform reference can only be used with package reference type.
234+
Otherwise, the specified platform will be replaced with AnyCPU in the build
235+
process.
219236

220-
For .NET, all 4 reference types are supported:
237+
### Building Tests with ReferenceType
238+
239+
For .NET:
221240

222241
```bash
242+
# Project is the default reference type. The below commands are equivalent:
243+
msbuild -t:BuildTestsNetCore
223244
msbuild -t:BuildTestsNetCore -p:ReferenceType=Project
224-
# Default setting uses Project Reference.
225245

246+
# Package reference type:
226247
msbuild -t:BuildTestsNetCore -p:ReferenceType=Package
227248
```
228249

229-
For .NET Framework, below reference types are supported:
250+
For .NET Framework:
230251

231252
```bash
253+
# Project is the default reference type. The below commands are equivalent:
254+
msbuild -t:BuildTestsNetFx -p:TF=net462
232255
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:ReferenceType=Project
233-
# Default setting uses Project Reference.
234256

257+
# Package reference type:
235258
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:ReferenceType=Package
236259
```
237260

@@ -250,26 +273,25 @@ Tests can be built and run with custom Target Frameworks. See the below examples
250273
### Building Tests with custom target framework
251274

252275
```bash
253-
msbuild -t:BuildTestsNetFx -p:TF=net462
254276
# Build the tests for custom .NET Framework target
277+
msbuild -t:BuildTestsNetFx -p:TF=net462
255278
```
256279

257280
```bash
258-
msbuild -t:BuildTestsNetCore -p:TF=net8.0
259281
# Build the tests for custom .NET target
282+
msbuild -t:BuildTestsNetCore -p:TF=net8.0
260283
```
261284

262285
### Running Tests with custom target framework (traditional)
263286

264287
```bash
288+
# Run tests with custom .NET Framework target
265289
dotnet test -p:TargetNetFxVersion=net462 ...
266-
# Use above property to run Functional Tests with custom .NET Framework target
267290

291+
# Run tests with custom .NET target
268292
dotnet test -p:TargetNetCoreVersion=net8.0 ...
269-
# Use above property to run Functional Tests with custom .NET target
270293
```
271294

272-
273295
## Using Managed SNI on Windows
274296

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

295317
`Switch.Microsoft.Data.SqlClient.SuppressInsecureTLSWarning`
296318

297-
### Troubleshooting Docker issues
298-
299-
There may be times where connection cannot be made to SQL Server, we found below ideas helpful:
300-
301-
- 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.
302-
303-
- 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:
304-
305-
```xml
306-
<OSGroup>Unix</OSGroup>
307-
<TargetsWindows>false</TargetsWindows>
308-
<TargetsUnix>true</TargetsUnix>
309-
```
310-
311319
## Collecting Code Coverage
312320

313321
### Using VSTest

0 commit comments

Comments
 (0)