Skip to content

Commit b96fbdb

Browse files
authored
Azure Split - Step 1 - Prep Work (dotnet#3902)
1 parent 19d0c57 commit b96fbdb

97 files changed

Lines changed: 1559 additions & 1223 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: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ name: "CodeQL Advanced"
1313

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

@@ -84,9 +84,22 @@ jobs:
8484
- name: Run manual build steps
8585
if: matrix.build-mode == 'manual'
8686
shell: bash
87+
# TODO(https://sqlclientdrivers.visualstudio.com/ADO.Net/_workitems/edit/41729):
88+
# For some reason, the StressTests projects fail to restore in this
89+
# environment, so we skip them by explicitly building all of the other
90+
# projects instead of the main solution file.
8791
run: |
88-
mkdir packages
89-
dotnet build src/
92+
dotnet build src/Microsoft.SqlServer.Server
93+
dotnet build src/Microsoft.Data.SqlClient/netcore/ref
94+
dotnet build src/Microsoft.Data.SqlClient/netcore/src
95+
dotnet build src/Microsoft.Data.SqlClient/netfx/ref
96+
dotnet build src/Microsoft.Data.SqlClient/netfx/src
97+
dotnet build src/Microsoft.Data.SqlClient/src
98+
dotnet build src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider
99+
dotnet build src/Microsoft.Data.SqlClient/tests/UnitTests
100+
dotnet build src/Microsoft.Data.SqlClient/tests/FunctionalTests
101+
dotnet build src/Microsoft.Data.SqlClient/tests/ManualTests
102+
dotnet build src/Microsoft.Data.SqlClient/tests/PerformanceTests
90103
91104
- name: Perform CodeQL Analysis
92105
uses: github/codeql-action/analyze@v4

BUILDGUIDE.md

Lines changed: 76 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ 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
|-|-|
3032
|`BuildAllConfigurations`|Default target. Builds the .NET Framework and .NET drivers for all target frameworks and operating systems.|
@@ -33,33 +35,34 @@ Once the environment is setup properly, execute the desired set of commands belo
3335
|`BuildNetFx`|Builds the .NET Framework driver for all target frameworks.|
3436
|`BuildTestsNetCore`|Builds tests for the .NET driver.|
3537
|`BuildTestsNetFx`|Builds tests for the .NET Framework driver.|
36-
|`Clean`|Cleans generated files.|
37-
|`Restore`|Restores Nuget packages.|
38+
|`Clean`|Cleans all generated files.|
39+
|`Restore`|Restores NuGet packages.|
3840
|`RunTests`|Runs the unit, functional, and manual tests for the .NET Framework and .NET drivers|
3941
|`RunUnitTests`|Runs just the unit tests for the .NET Framework and .NET drivers|
4042
|`RunFunctionalTests`|Runs just the functional tests for the .NET Framework and .NET drivers|
4143
|`RunManualTests`|Runs just the manual tests for the .NET Framework and .NET drivers|
4244
|`BuildAkv`|Builds the Azure Key Vault Provider package for all supported platforms.|
4345

44-
4546
### Parameters
47+
48+
The following parameters may be defined as MSBuild properties to configure the
49+
build:
50+
4651
|Name|Supported Values|Default|Description|
4752
|-|-|-|-|
4853
|`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.|
5054
|`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.|
5155
|`Platform`|`AnyCPU`, `x86`, `x64`, `ARM`, `ARM64`|`AnyCPU`|May only be set when using package reference type or running tests.|
5256
|`TestSet`|`1`, `2`, `3`, `AE`|all|Build or run a subset of the manual tests. Omit (default) to target all tests.|
5357
|`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\)|
5458
|`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.|
5559
|`ResultsDirectory`|An absolute file path|./TestResults relative to current directory|Specifies where to write test results.|
5660

57-
5861
## Example Workflows using MSBuild (Recommended)
62+
5963
Using the default configuration and running all tests:
6064

6165
```bash
62-
msbuild
6366
msbuild -t:BuildTestsNetFx -p:TF=net462
6467
msbuild -t:BuildTestsNetCore
6568
msbuild -t:RunTests
@@ -68,28 +71,25 @@ msbuild -t:RunTests
6871
Using the Release configuration:
6972

7073
```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
74+
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:Configuration=Release
75+
msbuild -t:BuildTestsNetCore -p:Configuration=Release
76+
msbuild -t:RunTests -p:Configuration=Release
7577
```
7678

7779
Running only the unit tests:
7880

7981
```bash
80-
msbuild
8182
msbuild -t:BuildTestsNetFx -p:TF=net462
8283
msbuild -t:BuildTestsNetCore
8384
msbuild -t:RunUnitTests
8485
```
8586

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

8889
```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\
90+
msbuild -t:BuildTestsNetFx -p:TF=net462
91+
msbuild -t:BuildTestsNetCore
92+
msbuild -t:RunTests -p:DotnetPath=C:\net8-win-x86\
9393
```
9494

9595
### Running Manual Tests
@@ -117,7 +117,7 @@ Manual Tests require the below setup to run:
117117
|AADSecurePrincipalSecret | (Optional) A Secret defined for a registered application which has been granted permission to the database defined in the AADPasswordConnectionString. | {Secret} |
118118
|AzureKeyVaultURL | (Optional) Azure Key Vault Identifier URL | `https://{keyvaultname}.vault.azure.net/` |
119119
|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`|
120+
|SupportsIntegratedSecurity | (Optional) Whether or not the USER running tests has integrated security access to the target SQL Server.| `true` OR `false`|
121121
|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.|
122122
|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. |
123123
|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 +128,13 @@ Manual Tests require the below setup to run:
128128
|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`. |
129129
|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` |
130130

131-
132131
## Example workflows using the Dotnet SDK
133132

134-
#### Run Functional Tests
133+
### Run Functional Tests
135134

136135
- Windows (`netfx x86`):
137136

138137
```bash
139-
msbuild
140138
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"
141139
```
142140

@@ -147,11 +145,11 @@ dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.S
147145
```
148146

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

153151
Windows (`netcoreapp`):
154-
152+
155153
```bash
156154
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"
157155
```
@@ -161,7 +159,8 @@ dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.S
161159
```bash
162160
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"
163161
```
164-
#### Run Manual Tests
162+
163+
### Run Manual Tests
165164

166165
- Windows (`netfx x86`):
167166

@@ -199,39 +198,73 @@ dotnet test "src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlCl
199198
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"
200199
```
201200

202-
## Testing with Custom ReferenceType
201+
## Testing with Package References
202+
203+
The MDS driver consists of several components, each of which produces its own
204+
NuGet package. During development, components reference each other via
205+
`<ProjectReference>` properties by default. This means that building
206+
and testing one component will implicitly build its project referenced
207+
dependencies.
203208

204-
Tests can be built and run with custom "Reference Type" property that enables different styles of testing:
209+
Alternatively, the `ReferenceType` build property may be specified with a value
210+
of `Package`. This will change inter-component dependencies to use
211+
`<PackageReference>` dependencies, and require that dependent components be
212+
built and packaged before building the depending component. In this scenario,
213+
the root `NuGet.config` file must be updated to include the following entry
214+
under the `<packageSources>` element:
205215

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.
216+
```xml
217+
<configuration>
218+
<packageSources>
219+
...
220+
<add key="local" value="packages/" />
221+
</packageSources>
222+
</configuration>
223+
```
208224

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-
> ```
225+
As a convenience, a `NuGet.config.local` file is supplied with the above
226+
package source already present. You may simply copy it over `NuGet.config`
227+
when using `Package` references.
215228

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.
229+
Then, you can specify `Package` references be used, for example:
217230

218-
### Building Tests with Reference Type
231+
```bash
232+
cp NuGet.config.local NuGet.config
233+
dotnet build -t:BuildAll -p:ReferenceType=Package
234+
dotnet build -t:BuildAKVNetCore -p:ReferenceType=Package
235+
dotnet build -t:GenerateMdsPackage
236+
dotnet build -t:GenerateAkvPackage
237+
dotnet build -t:BuildTestsNetCore -p:ReferenceType=Package
238+
```
219239

220-
For .NET, all 4 reference types are supported:
240+
The above will build the MDS and AKV components, place their NuGet packages into
241+
the `packages/` directory, and then build the tests using those packages.
242+
243+
A non-AnyCPU platform reference can only be used with package reference type.
244+
Otherwise, the specified platform will be replaced with AnyCPU in the build
245+
process.
246+
247+
### Building Tests with ReferenceType
248+
249+
For .NET:
221250

222251
```bash
252+
# Project is the default reference type. The below commands are equivalent:
253+
msbuild -t:BuildTestsNetCore
223254
msbuild -t:BuildTestsNetCore -p:ReferenceType=Project
224-
# Default setting uses Project Reference.
225255

256+
# Package reference type:
226257
msbuild -t:BuildTestsNetCore -p:ReferenceType=Package
227258
```
228259

229-
For .NET Framework, below reference types are supported:
260+
For .NET Framework:
230261

231262
```bash
263+
# Project is the default reference type. The below commands are equivalent:
264+
msbuild -t:BuildTestsNetFx -p:TF=net462
232265
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:ReferenceType=Project
233-
# Default setting uses Project Reference.
234266

267+
# Package reference type:
235268
msbuild -t:BuildTestsNetFx -p:TF=net462 -p:ReferenceType=Package
236269
```
237270

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

252285
```bash
253-
msbuild -t:BuildTestsNetFx -p:TF=net462
254286
# Build the tests for custom .NET Framework target
287+
msbuild -t:BuildTestsNetFx -p:TF=net462
255288
```
256289

257290
```bash
258-
msbuild -t:BuildTestsNetCore -p:TF=net8.0
259291
# Build the tests for custom .NET target
292+
msbuild -t:BuildTestsNetCore -p:TF=net8.0
260293
```
261294

262295
### Running Tests with custom target framework (traditional)
263296

264297
```bash
298+
# Run tests with custom .NET Framework target
265299
dotnet test -p:TargetNetFxVersion=net462 ...
266-
# Use above property to run Functional Tests with custom .NET Framework target
267300

301+
# Run tests with custom .NET target
268302
dotnet test -p:TargetNetCoreVersion=net8.0 ...
269-
# Use above property to run Functional Tests with custom .NET target
270303
```
271304

272-
273305
## Using Managed SNI on Windows
274306

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

295327
`Switch.Microsoft.Data.SqlClient.SuppressInsecureTLSWarning`
296328

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-
311329
## Collecting Code Coverage
312330

313331
### Using VSTest

0 commit comments

Comments
 (0)