Skip to content

Commit 6da35be

Browse files
committed
Align pack docs with dotnet build and harden SqlClient nuspec prep
1 parent a31e7e8 commit 6da35be

3 files changed

Lines changed: 58 additions & 56 deletions

File tree

BUILDGUIDE.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ on operating systems that do not support .NET Framework. As such, it is not nece
2020
no action is required. On Linux and MacOS systems, the `pwsh` command is required to be in the `$PATH` environment
2121
variable. For specific instructions see: [Install PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell)
2222

23-
The **NuGet** binary is required to package the Microsoft.Data.SqlClient project. For convenience, this can be be done
24-
via the PowerShell script [tools/scripts/downloadLatestNuget.ps1](tools/scripts/downloadLatestNuget.ps1), however, any
25-
`nuget.exe` binary can be used.
23+
The **NuGet** binary is optional for inspection and feed-management workflows, but build and packaging flows in this
24+
repository are run through `dotnet build` against `build.proj`.
2625

2726
## Developer Workflow
2827

@@ -35,20 +34,18 @@ package the project. The `build.proj` file provides convenient targets to accomp
3534
> is recommended that `build.proj` is used for local development, as well.
3635
3736
> [!TIP]
38-
> `build.proj` was written with the intention of being called from `msbuild`. As such, the following examples below
39-
> use `msbuild`. On systems where `msbuild` is not available, simply replace `msbuild` with `dotnet msbuild` to get the
40-
> same behavior.
37+
> Use `dotnet build` with `build.proj` for local and CI workflows in this repository.
4138
4239
> [!TIP]
4340
> This section is not exhaustive of all targets or parameters to `build.proj`. Complete documentation is avilable in
4441
> [`build.proj`](build.proj).
4542
4643
### Building Projects
4744

48-
From the root of your repository, run `msbuild` against `build.proj` with a build target, following this pattern:
45+
From the root of your repository, run `dotnet build` against `build.proj` with a build target, following this pattern:
4946

5047
```bash
51-
msbuild build.proj -t:<build_target> [optional_parameters]
48+
dotnet build build.proj -t:<build_target> [optional_parameters]
5249
```
5350

5451
The following build targets can be used to build the following projects. All targets will implicitly build any other
@@ -87,28 +84,28 @@ placed in `artifacts/Microsoft.Data.SqlClient.ref/Project-<configuration>/<tfm>`
8784

8885
Build all projects:
8986
```bash
90-
msbuild build.proj -t:Build
87+
dotnet build build.proj -t:Build
9188
```
9289

9390
Build Microsoft.Data.SqlClient in Release configuration:
9491
```bash
95-
msbuild build.proj -t:BuildSqlClient -p:Configuration=Release
92+
dotnet build build.proj -t:BuildSqlClient -p:Configuration=Release
9693
```
9794

9895
Build v1.2.3 of Microsoft.Data.SqlClient.Extensions.Abstractions:
9996
```bash
100-
msbuild build.proj -t:BuildAbstractions -p:PackageVersion=1.2.3
97+
dotnet build build.proj -t:BuildAbstractions -p:PackageVersion=1.2.3
10198
```
10299

103100
### Testing Projects
104101

105102
This section provides a summary and brief example of how to execute tests for projects in this repository. **For more
106103
information about test procedures, including config file setup, see [TESTGUIDE.md](TESTGUIDE.md).**
107104

108-
From the root of your repository, run `msbuild` against `build.proj` with a test target, following this pattern:
105+
From the root of your repository, run `dotnet build` against `build.proj` with a test target, following this pattern:
109106

110107
```bash
111-
msbuild build.proj -t:<test_target> [optional_parameters]
108+
dotnet build build.proj -t:<test_target> [optional_parameters]
112109
```
113110

114111
| `<test_target>` | Description |
@@ -140,37 +137,37 @@ A selection of parameters for test targets in `build.proj` relevant to common de
140137
Run Microsoft.Data.SqlClient unit tests:
141138

142139
```bash
143-
msbuild build.proj -t:TestSqlClientUnit
140+
dotnet build build.proj -t:TestSqlClientUnit
144141
```
145142

146143
Run Microsoft.Data.SqlClient manual test set 2:
147144
```bash
148-
msbuild build.proj -t:TestSqlClientManual -p:TestSet=2
145+
dotnet build build.proj -t:TestSqlClientManual -p:TestSet=2
149146
```
150147

151148
Run Microsoft.Data.SqlClient functional tests against x86 dotnet:
152149
```bash
153-
msbuild build.proj -t:TestSqlClientFunctional -p:DotnetPath='C:\path\to\dotnet\x86\'
150+
dotnet build build.proj -t:TestSqlClientFunctional -p:DotnetPath='C:\path\to\dotnet\x86\'
154151
```
155152

156153
Run all Microsoft.Data.SqlClient.Extensions.Azure unit tests, including interactive, but excluding failing tests:
157154
```bash
158-
msbuild build.proj -t:TestAzure -p:TestFilters=category!=failing
155+
dotnet build build.proj -t:TestAzure -p:TestFilters=category!=failing
159156
```
160157

161158
Run Microsoft.Data.SqlClient functional tests against net8.0 runtime:
162159
```bash
163-
msbuild build.proj -t:TestSqlClientFunctional -p:TestFramework=net8.0
160+
dotnet build build.proj -t:TestSqlClientFunctional -p:TestFramework=net8.0
164161
```
165162

166163
### Packaging Projects
167164

168165
Just like bulding and testing the various projects in this repository, packaging the projects into NuGet packages is
169-
also handle by `build.proj`. From the root of your repository, run `msbuild` against `build.proj` with a test target,
166+
also handle by `build.proj`. From the root of your repository, run `dotnet build` against `build.proj` with a pack target,
170167
following this pattern:
171168

172169
```bash
173-
msbuild build.proj -t:<pack_target> [optional_parameters]
170+
dotnet build build.proj -t:<pack_target> [optional_parameters]
174171
```
175172

176173
| `<build_target>` | Desription |
@@ -191,30 +188,34 @@ A selection of parameters for pack targets in `build.proj` relevant to common de
191188
| `[optional_parameter]` | Default Value | Allowed Values | Description |
192189
|------------------------------------|---------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
193190
| `-p:Configuration=` | `Debug` | `Debug`, `Release` | Build configuration. Only applies if project and dependencies are being built. |
194-
| `-p:NugetPath=` | `[blank]` | eg. `C:\my\nuget.exe` | _Only applies to `PackSqlClient`._ Path to `nuget.exe` that to use. If not provided, defaults to `nuget.exe` in the PATH. |
195191
| `-p:PackBuild=` | `true` | `true`, `false` | Whether or not to build the project before packing. If `false`, project must be built using the same parameters. |
196192
| `-p:PackageVersion<TargetProject>` | `[blank]` | eg. `1.2.3-dev123` | Version to assign to the package. If `PackBuild` is `true`, the assembly and file versions will be derived from this version. See Versioning for more details. |
197193

194+
For `PackSqlClient`, these additional parameters are required because dependency versions are injected into the SqlClient nuspec during pack:
195+
196+
- `-p:PackageVersionAbstractions=<version>`
197+
- `-p:PackageVersionLogging=<version>`
198+
198199
#### Examples
199200

200201
Package Microsoft.Data.SqlClient.Internal.Logging into a NuGet package:
201202
```bash
202-
msbuild build.proj -t:PackLogging
203+
dotnet build build.proj -t:PackLogging
203204
```
204205

205-
Package Microsoft.Data.SqlClient if `nuget.exe` is not in the `$PATH` environment variable:
206+
Package Microsoft.Data.SqlClient:
206207
```bash
207-
msbuild build.proj -t:PackSqlClient -p:NugetPath="C:\my\nuget.exe"
208+
dotnet build build.proj -t:PackSqlClient -p:PackageVersionAbstractions=<version> -p:PackageVersionLogging=<version>
208209
```
209210

210211
Package version 1.2.3 of Microsoft.Data.SqlClient.Extensions.Abstractions:
211212
```bash
212-
msbuild build.proj -t:PackAbstractions -p:PackageVersionAbstractions=1.2.3
213+
dotnet build build.proj -t:PackAbstractions -p:PackageVersionAbstractions=1.2.3
213214
```
214215

215216
Package version Microsoft.Data.SqlClient.Extensions.Azure without building it beforehand:
216217
```bash
217-
msbuild build.proj -t:PackAzure -p:PackBuild=false
218+
dotnet build build.proj -t:PackAzure -p:PackBuild=false
218219
```
219220

220221
## Versioning
@@ -276,20 +277,20 @@ and Microsoft.Data.SqlClient.Internal.Logging v2.2.2.
276277

277278
```bash
278279
# Build v2.2.2 of Logging and copy to packages
279-
msbuild build.proj -t:PackLogging \
280+
dotnet build build.proj -t:PackLogging \
280281
-p:ReferenceType=Package \
281282
-p:PackageVersionLogging=2.2.2
282283
cp artifacts/Microsoft.Data.SqlClient.Internal.Logging/Debug/*.*pkg packages/
283284

284285
# Build v1.0.1 of Abstractions that depends on v2.2.2 of Logging
285-
msbuild build.proj -t:PackAbstractions \
286+
dotnet build build.proj -t:PackAbstractions \
286287
-p:ReferenceType=Package \
287288
-p:PackageVersionAbstractions=1.0.1 \
288289
-p:PackageVersionLogging=2.2.2 \
289290
cp artifacts/Microsoft.Data.SqlClient.Extensions.Abstractions/Package-Debug/*.*pkg packages/
290291

291292
# Build SqlClient
292-
msbuild -t:PackSqlClient \
293+
dotnet build build.proj -t:PackSqlClient \
293294
-p:ReferenceType=Package \
294295
-p:PackageVersionSqlClient=7.1.1 \
295296
-p:PackageVersionAbstractions=1.0.1 \
@@ -299,7 +300,7 @@ cp artifacts/Microsoft.Data.SqlClient/Package-Debug/*.*pkg packages/
299300

300301
Run Microsoft.Data.SqlClient functional tests against the versions build above:
301302
```bash
302-
msbuild build.proj -t:TestSqlClientFunctional \
303+
dotnet build build.proj -t:TestSqlClientFunctional \
303304
-p:ReferenceType=Package \
304305
-p:PackageVersionSqlClient=7.1.1 \
305306
-p:PackageVersionAbstractions=1.0.1 \

TESTGUIDE.md

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ These projects target `net8.0`, `net9.0`, and `net10.0` on all platforms. On Win
2323
Use [build.proj](build.proj) from the repository root:
2424

2525
```bash
26-
msbuild build.proj -t:<test_target> [optional_parameters]
27-
```
28-
29-
If `msbuild` is not available, use `dotnet msbuild`:
30-
31-
```bash
32-
dotnet msbuild build.proj -t:<test_target> [optional_parameters]
26+
dotnet build build.proj -t:<test_target> [optional_parameters]
3327
```
3428

3529
Test targets build the projects they depend on, so a separate build step is not required for normal test runs.
@@ -51,55 +45,55 @@ Test targets build the projects they depend on, so a separate build step is not
5145
Run the SqlClient unit tests:
5246

5347
```bash
54-
msbuild build.proj -t:TestSqlClientUnit
48+
dotnet build build.proj -t:TestSqlClientUnit
5549
```
5650

5751
Run the SqlClient functional tests:
5852

5953
```bash
60-
msbuild build.proj -t:TestSqlClientFunctional
54+
dotnet build build.proj -t:TestSqlClientFunctional
6155
```
6256

6357
Run the SqlClient manual tests:
6458

6559
```bash
66-
msbuild build.proj -t:TestSqlClientManual
60+
dotnet build build.proj -t:TestSqlClientManual
6761
```
6862

6963
Run only manual test set 2:
7064

7165
```bash
72-
msbuild build.proj -t:TestSqlClientManual -p:TestSet=2
66+
dotnet build build.proj -t:TestSqlClientManual -p:TestSet=2
7367
```
7468

7569
Run manual test sets 1 and 3:
7670

7771
```bash
78-
msbuild build.proj -t:TestSqlClientManual -p:TestSet=13
72+
dotnet build build.proj -t:TestSqlClientManual -p:TestSet=13
7973
```
8074

8175
Run Always Encrypted manual tests:
8276

8377
```bash
84-
msbuild build.proj -t:TestSqlClientManual -p:TestSet=AE
78+
dotnet build build.proj -t:TestSqlClientManual -p:TestSet=AE
8579
```
8680

8781
Run a specific target framework:
8882

8983
```bash
90-
msbuild build.proj -t:TestSqlClientFunctional -p:TestFramework=net8.0
84+
dotnet build build.proj -t:TestSqlClientFunctional -p:TestFramework=net8.0
9185
```
9286

9387
Run functional tests against an x86 `dotnet` installation:
9488

9589
```bash
96-
msbuild build.proj -t:TestSqlClientFunctional -p:DotnetPath='C:\path\to\dotnet\x86\'
90+
dotnet build build.proj -t:TestSqlClientFunctional -p:DotnetPath='C:\path\to\dotnet\x86\'
9791
```
9892

9993
Run all Azure extension tests, including `interactive` tests, while still excluding tests marked `failing` or `flaky`:
10094

10195
```bash
102-
msbuild build.proj -t:TestAzure -p:TestFilters=category!=failing
96+
dotnet build build.proj -t:TestAzure -p:TestFilters=category!=failing
10397
```
10498

10599
## Test Parameters
@@ -132,13 +126,13 @@ Examples:
132126

133127
```bash
134128
# Run a single test by fully-qualified name.
135-
msbuild build.proj -t:TestSqlClientUnit -p:TestFilters=FullyQualifiedName=Namespace.ClassName.MethodName
129+
dotnet build build.proj -t:TestSqlClientUnit -p:TestFilters=FullyQualifiedName=Namespace.ClassName.MethodName
136130

137131
# Run only flaky tests while investigating quarantine failures.
138-
msbuild build.proj -t:TestSqlClientManual -p:TestFilters=category=flaky
132+
dotnet build build.proj -t:TestSqlClientManual -p:TestFilters=category=flaky
139133

140134
# Disable the default filter.
141-
msbuild build.proj -t:TestSqlClientFunctional -p:TestFilters=none
135+
dotnet build build.proj -t:TestSqlClientFunctional -p:TestFilters=none
142136
```
143137

144138
When passing filter expressions that contain shell-sensitive characters such as `&`, quote or escape the value as
@@ -222,14 +216,14 @@ For SQL Server in a Linux container, WSL, or another host where SQL authenticati
222216
You can override the config file path with the `MDS_TEST_CONFIG` environment variable:
223217

224218
```bash
225-
MDS_TEST_CONFIG=/path/to/config.json msbuild build.proj -t:TestSqlClientManual -p:TestSet=2
219+
MDS_TEST_CONFIG=/path/to/config.json dotnet build build.proj -t:TestSqlClientManual -p:TestSet=2
226220
```
227221

228222
On PowerShell:
229223

230224
```powershell
231225
$env:MDS_TEST_CONFIG = "C:\path\to\config.json"
232-
msbuild build.proj -t:TestSqlClientManual -p:TestSet=2
226+
dotnet build build.proj -t:TestSqlClientManual -p:TestSet=2
233227
```
234228

235229
## Configuration Properties
@@ -289,23 +283,23 @@ If `TestSet` is omitted, all sets are compiled and run. You can combine sets by
289283
Test results are written to `test_results` by default. Override the location with `TestResultsFolderPath`:
290284

291285
```bash
292-
msbuild build.proj -t:TestSqlClientUnit -p:TestResultsFolderPath=/tmp/sqlclient-test-results
286+
dotnet build build.proj -t:TestSqlClientUnit -p:TestResultsFolderPath=/tmp/sqlclient-test-results
293287
```
294288

295289
Hang blame collection is enabled by default with a `10m` timeout. To increase the timeout:
296290

297291
```bash
298-
msbuild build.proj -t:TestSqlClientManual -p:TestBlameTimeout=30m
292+
dotnet build build.proj -t:TestSqlClientManual -p:TestBlameTimeout=30m
299293
```
300294

301295
To disable hang blame collection:
302296

303297
```bash
304-
msbuild build.proj -t:TestSqlClientManual -p:TestBlameTimeout=0
298+
dotnet build build.proj -t:TestSqlClientManual -p:TestBlameTimeout=0
305299
```
306300

307301
Code coverage is enabled by default. To disable it for a faster local run:
308302

309303
```bash
310-
msbuild build.proj -t:TestSqlClientUnit -p:TestCodeCoverage=false
304+
dotnet build build.proj -t:TestSqlClientUnit -p:TestCodeCoverage=false
311305
```

src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<SqlClientPackNuspecGeneratedPath Condition="'$(SqlClientPackNuspecGeneratedPath)' == ''">$(BaseIntermediateOutputPath)Microsoft.Data.SqlClient.pack.nuspec</SqlClientPackNuspecGeneratedPath>
8484

8585
<NuspecVersion Condition="'$(NuspecVersion)' == ''">$(Version)</NuspecVersion>
86-
<NuspecFile Condition="'$(NuspecFile)' == ''">$(RepoRoot)tools/specs/Microsoft.Data.SqlClient.nuspec</NuspecFile>
86+
<NuspecFile Condition="'$(NuspecFile)' == ''">$(SqlClientPackNuspecTemplatePath)</NuspecFile>
8787
<NuspecBasePath Condition="'$(NuspecBasePath)' == ''">$([System.IO.Path]::GetDirectoryName('$(SqlClientPackNuspecTemplatePath)'))</NuspecBasePath>
8888
<IncludeSymbols Condition="'$(IncludeSymbols)' == ''">true</IncludeSymbols>
8989
<SymbolPackageFormat Condition="'$(SymbolPackageFormat)' == ''">snupkg</SymbolPackageFormat>
@@ -99,6 +99,13 @@
9999
<Target Name="PrepareSqlClientPackNuspec"
100100
BeforeTargets="GenerateNuspec"
101101
Condition="'$(NuspecFile)' == '$(SqlClientPackNuspecTemplatePath)'">
102+
<Error Text="PrepareSqlClientPackNuspec requires AbstractionsPackageVersion. Specify -p:PackageVersionAbstractions=&lt;version&gt;."
103+
Condition="'$(AbstractionsPackageVersion)' == ''" />
104+
<Error Text="PrepareSqlClientPackNuspec requires LoggingPackageVersion. Specify -p:PackageVersionLogging=&lt;version&gt;."
105+
Condition="'$(LoggingPackageVersion)' == ''" />
106+
<Error Text="PrepareSqlClientPackNuspec requires NuspecVersion. Specify -p:NuspecVersion=&lt;version&gt;."
107+
Condition="'$(NuspecVersion)' == ''" />
108+
102109
<PropertyGroup>
103110
<_SqlClientPackNuspecExpandedText>$([System.IO.File]::ReadAllText('$(SqlClientPackNuspecTemplatePath)').Replace('$AbstractionsPackageVersion$','$(AbstractionsPackageVersion)').Replace('$LoggingPackageVersion$','$(LoggingPackageVersion)').Replace('<version>1.0.0</version>','<version>$(NuspecVersion)</version>'))</_SqlClientPackNuspecExpandedText>
104111
</PropertyGroup>

0 commit comments

Comments
 (0)