You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: BUILDGUIDE.md
+66-58Lines changed: 66 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,41 +25,46 @@ Once the environment is setup properly, execute the desired set of commands belo
25
25
26
26
### Targets
27
27
28
+
The following build targets are defined in `build.proj`:
29
+
28
30
|Target|Description|
29
31
|-|-|
32
+
|`BuildAbstractions`|Restore, build, and pack the Abstractions package, publishing the resulting NuGet into `packages/`.|
30
33
|`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/`.|
31
35
|`BuildNetCore`|Builds the .NET driver for all target frameworks.|
32
36
|`BuildNetCoreAllOS`|Builds the .NET driver for all target frameworks and operating systems.|
33
37
|`BuildNetFx`|Builds the .NET Framework driver for all target frameworks.|
34
38
|`BuildTestsNetCore`|Builds tests for the .NET driver.|
35
39
|`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.|
38
42
|`RunTests`|Runs the unit, functional, and manual tests for the .NET Framework and .NET drivers|
39
43
|`RunUnitTests`|Runs just the unit tests for the .NET Framework and .NET drivers|
40
44
|`RunFunctionalTests`|Runs just the functional tests for the .NET Framework and .NET drivers|
41
45
|`RunManualTests`|Runs just the manual tests for the .NET Framework and .NET drivers|
42
46
|`BuildAkv`|Builds the Azure Key Vault Provider package for all supported platforms.|
43
47
44
-
45
48
### Parameters
49
+
50
+
The following parameters may be defined as MSBuild properties to configure the
51
+
build:
52
+
46
53
|Name|Supported Values|Default|Description|
47
54
|-|-|-|-|
48
55
|`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.|
50
56
|`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.|
51
57
|`Platform`|`AnyCPU`, `x86`, `x64`, `ARM`, `ARM64`|`AnyCPU`|May only be set when using package reference type or running tests.|
52
58
|`TestSet`|`1`, `2`, `3`, `AE`|all|Build or run a subset of the manual tests. Omit (default) to target all tests.|
53
59
|`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\)|
54
60
|`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.|
55
61
|`ResultsDirectory`|An absolute file path|./TestResults relative to current directory|Specifies where to write test results.|
56
62
57
-
58
63
## Example Workflows using MSBuild (Recommended)
64
+
59
65
Using the default configuration and running all tests:
@@ -117,7 +119,7 @@ Manual Tests require the below setup to run:
117
119
|AADSecurePrincipalSecret | (Optional) A Secret defined for a registered application which has been granted permission to the database defined in the AADPasswordConnectionString. | {Secret} |
|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`|
121
123
|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.|
122
124
|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. |
123
125
|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:
128
130
|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`. |
129
131
|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`|
130
132
131
-
132
133
## Example workflows using the Dotnet SDK
133
134
134
-
####Run Functional Tests
135
+
### Run Functional Tests
135
136
136
137
- Windows (`netfx x86`):
137
138
138
139
```bash
139
-
msbuild
140
140
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"
141
141
```
142
142
@@ -147,11 +147,11 @@ dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.S
147
147
```
148
148
149
149
- AnyCPU:
150
-
150
+
151
151
Project reference only builds Driver with `AnyCPU` platform, and underlying process decides to run the tests with a compatible architecture (x64, x86, ARM64).
152
152
153
153
Windows (`netcoreapp`):
154
-
154
+
155
155
```bash
156
156
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"
157
157
```
@@ -161,7 +161,8 @@ dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.S
161
161
```bash
162
162
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"
163
163
```
164
-
#### Run Manual Tests
164
+
165
+
### Run Manual Tests
165
166
166
167
- Windows (`netfx x86`):
167
168
@@ -199,39 +200,61 @@ dotnet test "src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlCl
199
200
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"
200
201
```
201
202
202
-
## Testing with Custom ReferenceType
203
+
## Testing with Package References
203
204
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.
205
210
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`).
208
217
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:
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.
217
232
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.
219
236
220
-
For .NET, all 4 reference types are supported:
237
+
### Building Tests with ReferenceType
238
+
239
+
For .NET:
221
240
222
241
```bash
242
+
# Project is the default reference type. The below commands are equivalent:
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:
0 commit comments