Skip to content

Commit bf917e9

Browse files
committed
- Added global.json to restrict our SDK to the single supported version, currently 9.0.
- Using global.json to install .NET SDKs everywhere except when we may need ARM64. - Removed unnecessary installation of .NET SDKs and runtimes where they aren't needed. - Added all target frameworks to the x86 test runs. - Updated documentation related to SDKs. - Removed runtime ARM64 architecture detection in favour of explicit parameters for the test jobs that use ARM64. - Suppressing CredScan errors related to test secrets.
1 parent 4dc47c9 commit bf917e9

19 files changed

+312
-267
lines changed

.config/CredScanSuppressions.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"tool": "Credential Scanner",
3-
"suppressions": [
3+
"suppressions":
4+
[
45
{
56
"file": "src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/TDSServerArguments.cs",
67
"justification": "Test projects should be skipped"
@@ -12,6 +13,14 @@
1213
{
1314
"file": "doc/samples/SqlConnectionStringBuilder.cs",
1415
"justification": "Documentation could include sample data and can be ignored"
16+
},
17+
{
18+
"file": "src/Microsoft.Data.SqlClient/tests/UnitTests/Fixtures/AlwaysEncrypted/NativeColumnEncryptionKeyCertificateBaselineFixture.cs",
19+
"justification": "Test projects should be skipped"
20+
},
21+
{
22+
"file": "src/Microsoft.Data.SqlClient/tests/UnitTests/Resources/AlwaysEncrypted/NativeColumnEncryptionKeyBaseline/Certificate.pfx",
23+
"justification": "Test projects should be skipped"
1524
}
1625
]
1726
}

BUILDGUIDE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
This document provides all the necessary details to build the driver and run tests present in the repository.
44

5+
## .NET SDK
6+
7+
The projects in this repo require the .NET 9.0 SDK to build. Please ensure you
8+
have the latest version of that SDK installed.
9+
10+
Tests and tools may require different .NET Runtimes that may be installed
11+
independently. For example, tests targeting .NET 8.0 will need that runtime
12+
installed.
13+
514
## Visual Studio Pre-Requisites
615

716
This project should be built with Visual Studio 2019+ for the best compatibility. The required set of components are provided in the below file:

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ When targeting .NET on Windows, a package reference to [Microsoft.Data.SqlClient
2727

2828
| Topic | Link to File |
2929
| :---- | :------------- |
30-
| Coding Style | [coding-style.md](/policy/coding-style.md) |
3130
| Best Practices | [coding-best-practices.md](/policy/coding-best-practices.md) |
32-
| Review Process | [review-process.md](/policy/review-process.md) |
33-
| Guidelines for building the driver | [BUILDGUIDE.md](BUILDGUIDE.md) |
34-
| Guidelines for Contributors | [CONTRIBUTING.md](CONTRIBUTING.md) |
35-
| Changelog for all driver releases | [CHANGELOG.md](CHANGELOG.md) |
36-
| Support Policy | [SUPPORT.md](SUPPORT.md) |
31+
| Build Guide | [BUILDGUIDE.md](/BUILDGUIDE.md) |
32+
| Changelog | [CHANGELOG.md](CHANGELOG.md) |
3733
| Code of Conduct | [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) |
34+
| Coding Style | [coding-style.md](/policy/coding-style.md) |
35+
| Contributing | [CONTRIBUTING.md](CONTRIBUTING.md) |
3836
| Copyright Information | [COPYRIGHT.md](COPYRIGHT.md) |
37+
| Review Process | [review-process.md](/policy/review-process.md) |
38+
| Support Policy | [SUPPORT.md](SUPPORT.md) |
3939

4040
## Our Featured Contributors
4141

eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ jobs:
4646
- ${{ if ne(parameters.prebuildSteps, '') }}:
4747
- ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration
4848

49+
# Install whichever .NET SDKs are specified in our global.json.
50+
- task: UseDotNet@2
51+
displayName: Install .NET SDKs
52+
inputs:
53+
packageType: sdk
54+
useGlobalJson: true
55+
4956
- template: ../steps/ci-project-build-step.yml@self
5057
parameters:
5158
platform: ${{ parameters.platform }}

eng/pipelines/common/templates/jobs/ci-code-coverage-job.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,21 @@ jobs:
6060
- pwsh: 'Get-ChildItem env: | Sort-Object Name'
6161
displayName: '[Debug] List Environment Variables'
6262

63-
- template: ../steps/ensure-dotnet-version.yml@self
64-
parameters:
65-
packageType: sdk
66-
version: '9.0'
63+
# Install whichever .NET SDKs are specified in our global.json.
64+
- task: UseDotNet@2
65+
displayName: Install .NET SDKs
66+
inputs:
67+
packageType: sdk
68+
useGlobalJson: true
69+
70+
- ${{ if eq(parameters.debug, true)}}:
71+
- pwsh: |
72+
Get-ChildItem $(Build.SourcesDirectory)\coverageNetFx\ -Recurse -File -Filter *.coverage
73+
displayName: 'List coverageNetFx files [debug]'
74+
75+
- pwsh: |
76+
Get-ChildItem $(Build.SourcesDirectory)\coverageNetCore\ -Recurse -File -Filter *.coverage
77+
displayName: 'List coverageNetCore files [debug]'
6778
6879
- pwsh: |
6980
dotnet tool install --global dotnet-coverage

eng/pipelines/common/templates/jobs/ci-run-tests-job.yml

Lines changed: 72 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ parameters:
8181
# The timeout, in minutes, for this job.
8282
- name: timeout
8383
type: number
84+
85+
# True if this is an ARM64 job.
86+
- name: isArm64
87+
type: boolean
88+
default: false
8489

8590
jobs:
8691
- job: ${{ format('{0}', coalesce(parameters.jobDisplayName, parameters.image, 'unknown_image')) }}
@@ -102,6 +107,46 @@ jobs:
102107
value: '$(dotnetx86Path)'
103108

104109
steps:
110+
111+
# Install .NET SDKs and runtimes. These may be needed for the pre-build
112+
# steps.
113+
#
114+
# We can use the standard UseDotNet@2 task for non-ARM64 jobs.
115+
- ${{ if eq(parameters.isArm64, false) }}:
116+
- task: UseDotNet@2
117+
displayName: Install .NET SDKs
118+
inputs:
119+
packageType: sdk
120+
useGlobalJson: true
121+
122+
- task: UseDotNet@2
123+
displayName: Install .NET 8 Runtime
124+
inputs:
125+
packageType: runtime
126+
version: 8.x
127+
128+
# For ARM64, we need to use our custom step to work around a bug in
129+
# UseDotNet@2:
130+
#
131+
# [BUG]: UseDotNet task installs x86 build
132+
# https://github.com/microsoft/azure-pipelines-tasks/issues/20300
133+
#
134+
- ${{ else }}:
135+
- template: ../../../steps/install-dotnet-arm64.yml@self
136+
parameters:
137+
debug: ${{ parameters.debug }}
138+
installType: SDK
139+
# GOTCHA: We always use global.json for SDK version except on ARM64,
140+
# where we have to specify it here. This must be kept synchronized with
141+
# the SDK version in global.json.
142+
version: 9.0
143+
144+
- template: ../../../steps/install-dotnet-arm64.yml@self
145+
parameters:
146+
debug: ${{ parameters.debug }}
147+
installType: Runtime
148+
version: 8.0
149+
105150
- ${{ if ne(parameters.prebuildSteps, '') }}:
106151
- ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration
107152

@@ -121,6 +166,12 @@ jobs:
121166
}
122167
displayName: 'Verify Password'
123168
169+
- ${{ if eq(parameters.buildType, 'Project') }}:
170+
- template: ../steps/ci-project-build-step.yml@self
171+
parameters:
172+
build: allNoDocs
173+
buildConfiguration: ${{ parameters.buildConfiguration }}
174+
124175
- ${{ if ne(parameters.configProperties, '{}') }}:
125176
- template: ../steps/update-config-file-step.yml@self # update config.json file
126177
parameters:
@@ -253,33 +304,28 @@ jobs:
253304
# it should be acceptable to just install a specific version in all cases.
254305
# @TODO: This setup is very confusing. Ideally we should just be utilizing the dotnet installation
255306
# earlier in the job. There has to be a cleaner way of doing this.
256-
# As it stands now, we install dotnet LTS if we're running netfx tests, and the appropriate netX
257-
# version if we're running netcore tests. Technically LTS is not supported by the UseDotNet task
258-
# but we know we're using install-dotnet since we're on windows (for now ... this will not work
259-
# forever and needs a serious rethinking).
260307
- ${{ if ne(variables['dotnetx86RootPath'], '') }}:
261-
- ${{ if startswith(parameters.targetFramework, 'net4')}}:
262-
- template: ../steps/ensure-dotnet-version.yml
263-
parameters:
264-
installDir: "$(dotnetx86RootPath)"
265-
packageType: "sdk"
266-
usePreview: "false"
267-
version: "LTS"
268-
windowsArchitecture: "x86"
269-
- ${{ else }}:
270-
- script: |
271-
set FrameworkVersion=${{ parameters.targetFramework }}
272-
echo %FrameworkVersion%
273-
set TrimmedFrameworkVersion=%FrameworkVersion:~3%
274-
echo %TrimmedFrameworkVersion%
275-
echo ##vso[task.setvariable variable=netVersionX86]%TrimmedFrameworkVersion%
276-
displayName: "Trim dotnet version"
277-
- template: ../steps/ensure-dotnet-version.yml
278-
parameters:
279-
installDir: "$(dotnetx86RootPath)"
280-
packageType: "sdk"
281-
usePreview: "false"
282-
version: $(netVersionX86)
308+
# Install whichever .NET SDKs are specified in our global.json.
309+
- task: UseDotNet@2
310+
displayName: Install .NET SDKs
311+
inputs:
312+
installationPath: $(dotnetx86RootPath)
313+
packageType: sdk
314+
useGlobalJson: true
315+
env:
316+
# Override the architecture to install for x86.
317+
PROCESSOR_ARCHITECTURE: x86
318+
319+
# Install the .NET 8.0 runtime to run tests that target it.
320+
- task: UseDotNet@2
321+
displayName: Install .NET 8.0 Runtime
322+
inputs:
323+
installationPath: $(dotnetx86RootPath)
324+
packageType: runtime
325+
version: 8.x
326+
env:
327+
# Override the architecture to install for x86.
328+
PROCESSOR_ARCHITECTURE: x86
283329

284330
- template: ../steps/run-all-tests-step.yml@self
285331
parameters:

eng/pipelines/common/templates/stages/ci-run-tests-stage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ stages:
7272
publishTestResults: true
7373
configSqlFor: ${{ config.value.configSqlFor }}
7474
operatingSystem: ${{ config.value.operatingSystem }}
75+
isArm64: ${{ eq(config.value.isArm64, 'true') }}
7576
${{if ne(config.value.configProperties, '{}') }}:
7677
${{ each x86TF in config.value.configProperties.x86TestTargetFrameworks }}:
7778
${{ if eq(x86TF, targetFramework) }}:
@@ -103,6 +104,7 @@ stages:
103104
publishTestResults: true
104105
configSqlFor: ${{ config.value.configSqlFor }}
105106
operatingSystem: ${{ config.value.operatingSystem }}
107+
isArm64: ${{ eq(config.value.isArm64, 'true') }}
106108
${{if and(eq(usemanagedSNI, false), ne(config.value.configProperties, '{}')) }}:
107109
${{ each x86TF in config.value.configProperties.x86TestTargetFrameworks }}:
108110
${{ if eq(x86TF, targetFramework) }}:

eng/pipelines/common/templates/steps/build-all-configurations-signed-dlls-step.yml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,23 @@ parameters:
2525
- MSS
2626

2727
steps:
28-
- task: DownloadSecureFile@1
29-
displayName: 'Download Key Pair'
30-
inputs:
31-
secureFile: netfxKeypair.snk
32-
retryCount: 5
33-
34-
- task: UseDotNet@2
35-
displayName: 'Use .NET 9.x sdk'
36-
inputs:
37-
packageType: sdk
38-
version: '9.x'
39-
40-
- task: UseDotNet@2
41-
displayName: 'Install .NET 8.x runtime'
42-
inputs:
43-
packageType: runtime
44-
version: '8.x'
28+
- task: DownloadSecureFile@1
29+
displayName: 'Download Key Pair'
30+
inputs:
31+
secureFile: netfxKeypair.snk
32+
retryCount: 5
4533

46-
- ${{ if eq(parameters.product, 'MDS') }}:
47-
- task: MSBuild@1
48-
displayName: 'BuildAllConfigurations using build.proj'
34+
# Install whichever .NET SDKs are specified in our global.json.
35+
- task: UseDotNet@2
36+
displayName: Install .NET SDKs
4937
inputs:
50-
solution: '**/build.proj'
51-
configuration: '${{parameters.buildConfiguration }}'
52-
msbuildArguments: '-p:AssemblyFileVersion=${{parameters.AssemblyFileVersion }} -t:BuildAllConfigurations -p:GenerateNuget=false -p:SigningKeyPath=$(Agent.TempDirectory)\netfxKeypair.snk'
38+
packageType: sdk
39+
useGlobalJson: true
40+
41+
- ${{ if eq(parameters.product, 'MDS') }}:
42+
- task: MSBuild@1
43+
displayName: 'BuildAllConfigurations using build.proj'
44+
inputs:
45+
solution: '**/build.proj'
46+
configuration: '${{parameters.buildConfiguration }}'
47+
msbuildArguments: '-p:AssemblyFileVersion=${{parameters.AssemblyFileVersion }} -t:BuildAllConfigurations -p:GenerateNuget=false -p:SigningKeyPath=$(Agent.TempDirectory)\netfxKeypair.snk'

eng/pipelines/common/templates/steps/ci-prebuild-step.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,6 @@ parameters:
2525
- Package
2626

2727
steps:
28-
- template: ensure-dotnet-version.yml
29-
parameters:
30-
packageType: sdk
31-
usePreview: false
32-
version: 9.0
33-
34-
- template: ensure-dotnet-version.yml
35-
parameters:
36-
packageType: runtime
37-
usePreview: false
38-
version: 8.0
39-
4028
- ${{if eq(parameters.debug, true)}}:
4129
- powershell: |
4230
Get-ChildItem env: | Sort-Object Name
@@ -55,9 +43,3 @@ steps:
5543
parameters:
5644
downloadedNugetPath: $(Pipeline.Workspace)\${{parameters.artifactName }}
5745
debug: ${{ parameters.debug }}
58-
59-
- ${{ else }}: # project
60-
- template: ci-project-build-step.yml@self
61-
parameters:
62-
build: allNoDocs
63-
buildConfiguration: ${{ parameters.buildConfiguration }}

eng/pipelines/common/templates/steps/ci-project-build-step.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ parameters:
3737
- allNoDocs
3838

3939
steps:
40-
- template: ./ensure-dotnet-version.yml@self
41-
parameters:
42-
packageType: 'sdk'
43-
version: '9.0'
44-
45-
- template: ./ensure-dotnet-version.yml@self
46-
parameters:
47-
packageType: 'runtime'
48-
version: '8.0'
49-
5040
- ${{ if or(eq(parameters.operatingSystem, 'Windows'), eq(parameters.operatingSystem, 'deferedToRuntime')) }}:
5141
- ${{ if or(eq(parameters.build, 'MDS'), eq(parameters.build, 'all'), eq(parameters.build, 'allNoDocs')) }}:
5242
- task: MSBuild@1

0 commit comments

Comments
 (0)