From 9bb6342f2dfec0621b60b09948315710e4ac1fef Mon Sep 17 00:00:00 2001 From: Paul Medynski <31868385+paulmedynski@users.noreply.github.com> Date: Fri, 21 Aug 2026 09:21:30 -0300 Subject: [PATCH 1/3] Add assembly signing for Microsoft.SqlServer.Server Introduce the shared signing-key download step and thread isInternalBuild through the CI core so the SqlServer package is strong-name signed on internal Package-mode builds. - Add eng/pipelines/common/steps/download-assembly-signing-key.yml, which exports driverKeyFile or testKeyFile from ADO secure files. - Adopt that step in the OneBranch build and nightly CI package pipelines, renaming keyFile to driverKeyFile. - Declare isInternalBuild in dotnet-sqlclient-ci-core.yml and set it from the CI package- and project-reference pipelines. - Sign the SqlServer package when isInternalBuild is true and referenceType is not Project. --- .../package/sqlclient-ci-package-pipeline.yml | 10 +--- .../steps/download-assembly-signing-key.yml | 39 +++++++++++++ eng/pipelines/dotnet-sqlclient-ci-core.yml | 8 +++ ...qlclient-ci-package-reference-pipeline.yml | 1 + ...qlclient-ci-project-reference-pipeline.yml | 1 + .../jobs/pack-sqlserver-package-ci-job.yml | 56 +++++++++++++++---- .../jobs/validate-signed-package-job.yml | 4 +- .../onebranch/steps/build-buildproj-step.yml | 10 +--- .../build-sqlserver-package-ci-stage.yml | 17 ++++++ 9 files changed, 118 insertions(+), 28 deletions(-) create mode 100644 eng/pipelines/common/steps/download-assembly-signing-key.yml diff --git a/eng/pipelines/ci/package/sqlclient-ci-package-pipeline.yml b/eng/pipelines/ci/package/sqlclient-ci-package-pipeline.yml index ada32431b2..f33614d97f 100644 --- a/eng/pipelines/ci/package/sqlclient-ci-package-pipeline.yml +++ b/eng/pipelines/ci/package/sqlclient-ci-package-pipeline.yml @@ -81,7 +81,7 @@ variables: value: ${{ eq(variables['System.TeamProject'], 'ADO.Net') }} # Signing key argument passed to build.proj. On internal builds this references the secure file - # downloaded by DownloadSecureFile@1; on public builds it expands to empty. + # downloaded by download-assembly-signing-key.yml; on public builds it expands to empty. - name: signingKeyArg ${{ if eq(variables.isInternalBuild, true) }}: value: -p:SigningKeyPath="$(driverKeyFile.secureFilePath)" @@ -125,13 +125,9 @@ jobs: Write-Host 'Done.' displayName: Clean Packages Directory - # On internal builds, download the strong-name signing key. + # On internal builds, download the assembly signing key. - ${{ if eq(variables.isInternalBuild, true) }}: - - task: DownloadSecureFile@1 - displayName: Download Driver Signing Key - inputs: - secureFile: netfxKeypair.snk - name: driverKeyFile + - template: /eng/pipelines/common/steps/download-assembly-signing-key.yml@self # Run the Pack target via build.proj. - task: DotNetCoreCLI@2 diff --git a/eng/pipelines/common/steps/download-assembly-signing-key.yml b/eng/pipelines/common/steps/download-assembly-signing-key.yml new file mode 100644 index 0000000000..0a58703319 --- /dev/null +++ b/eng/pipelines/common/steps/download-assembly-signing-key.yml @@ -0,0 +1,39 @@ +################################################################################ +# Licensed to the .NET Foundation under one or more agreements. The .NET +# Foundation licenses this file to you under the MIT license. See the LICENSE +# file in the project root for more information. +################################################################################ + +# Downloads a signing key from ADO secure files. +# +# When isTest is false, downloads the driver signing key and exports it as 'driverKeyFile'. When +# isTest is true, downloads the test signing key and exports it as 'testKeyFile'. +# +# Downstream steps reference the path via: +# +# $(driverKeyFile.secureFilePath) or +# $(testKeyFile.secureFilePath) + +parameters: + + # When false, download the driver signing key. + # When true, download the test signing key. + - name: isTest + type: boolean + default: false + +steps: + + - ${{ if eq(parameters.isTest, false) }}: + - task: DownloadSecureFile@1 + displayName: Download Driver Signing Key + inputs: + secureFile: netfxKeypair.snk + name: driverKeyFile + + - ${{ else }}: + - task: DownloadSecureFile@1 + displayName: Download Test Signing Key + inputs: + secureFile: sqlclient-test-key.snk + name: testKeyFile diff --git a/eng/pipelines/dotnet-sqlclient-ci-core.yml b/eng/pipelines/dotnet-sqlclient-ci-core.yml index 3e68e93325..2f42bf6e41 100644 --- a/eng/pipelines/dotnet-sqlclient-ci-core.yml +++ b/eng/pipelines/dotnet-sqlclient-ci-core.yml @@ -109,6 +109,12 @@ parameters: - detailed - diagnostic + # True when building on the internal ADO.Net project. Internal builds may perform additional or + # different steps, such as assembly signing. + - name: isInternalBuild + type: boolean + default: false + variables: - template: /eng/pipelines/libraries/ci-build-variables.yml@self @@ -149,6 +155,8 @@ stages: buildConfiguration: ${{ parameters.buildConfiguration }} debug: ${{ parameters.debug }} dotnetVerbosity: ${{ parameters.dotnetVerbosity }} + referenceType: ${{ parameters.referenceType }} + isInternalBuild: ${{ parameters.isInternalBuild }} # Build the Logging package, and publish it to the pipeline artifacts # under the given artifact name. This runs in parallel with the Secrets diff --git a/eng/pipelines/dotnet-sqlclient-ci-package-reference-pipeline.yml b/eng/pipelines/dotnet-sqlclient-ci-package-reference-pipeline.yml index c7fa90860f..ea94e62abf 100644 --- a/eng/pipelines/dotnet-sqlclient-ci-package-reference-pipeline.yml +++ b/eng/pipelines/dotnet-sqlclient-ci-package-reference-pipeline.yml @@ -178,3 +178,4 @@ extends: testJobTimeout: ${{ parameters.testJobTimeout }} testSets: ${{ parameters.testSets }} useManagedSNI: ${{ parameters.useManagedSNI }} + isInternalBuild: ${{ eq(variables['System.TeamProject'], 'ADO.Net') }} diff --git a/eng/pipelines/dotnet-sqlclient-ci-project-reference-pipeline.yml b/eng/pipelines/dotnet-sqlclient-ci-project-reference-pipeline.yml index 54a1b0e639..757a5b5dd8 100644 --- a/eng/pipelines/dotnet-sqlclient-ci-project-reference-pipeline.yml +++ b/eng/pipelines/dotnet-sqlclient-ci-project-reference-pipeline.yml @@ -178,3 +178,4 @@ extends: testJobTimeout: ${{ parameters.testJobTimeout }} testSets: ${{ parameters.testSets }} useManagedSNI: ${{ parameters.useManagedSNI }} + isInternalBuild: ${{ eq(variables['System.TeamProject'], 'ADO.Net') }} diff --git a/eng/pipelines/jobs/pack-sqlserver-package-ci-job.yml b/eng/pipelines/jobs/pack-sqlserver-package-ci-job.yml index 4f619b3f1b..dcf5c3b6c9 100644 --- a/eng/pipelines/jobs/pack-sqlserver-package-ci-job.yml +++ b/eng/pipelines/jobs/pack-sqlserver-package-ci-job.yml @@ -49,6 +49,21 @@ parameters: - detailed - diagnostic + # The C# project reference type to use when building and packing the packages. + - name: referenceType + type: string + default: Project + values: + # Reference sibling packages as NuGet packages. + - Package + # Reference sibling packages as C# projects. + - Project + + # True when building on the internal ADO.Net project. + - name: isInternalBuild + type: boolean + default: false + jobs: - job: pack_sqlserver_package_job @@ -94,19 +109,36 @@ jobs: parameters: debug: ${{ parameters.debug }} + # Download the assembly signing key for internal Package-mode builds. + - ${{ if and(eq(parameters.isInternalBuild, true), ne(parameters.referenceType, 'Project')) }}: + - template: /eng/pipelines/common/steps/download-assembly-signing-key.yml@self + # Create the NuGet packages. - - task: DotNetCoreCLI@2 - displayName: Create NuGet Package - inputs: - command: pack - packagesToPack: $(project) - configurationToPack: ${{ parameters.buildConfiguration }} - packDirectory: $(dotnetPackagesDir) - verbosityToPack: ${{ parameters.dotnetVerbosity }} - # BuildNumber supplies the revision component of FileVersion - # (Major.Minor.Patch.Revision). Without it, FileVersionBuildNumber - # defaults to 0 and the assembly is stamped Major.Minor.Patch.0. - buildProperties: SqlServerPackageVersion=${{ parameters.sqlServerPackageVersion }};BuildNumber=$(Build.BuildNumber) + # + # BuildNumber supplies the revision component of FileVersion + # (Major.Minor.Patch.Revision). Without it, FileVersionBuildNumber + # defaults to 0 and the assembly is stamped Major.Minor.Patch.0. + - ${{ if and(eq(parameters.isInternalBuild, true), ne(parameters.referenceType, 'Project')) }}: + - task: DotNetCoreCLI@2 + displayName: Create NuGet Package + inputs: + command: pack + packagesToPack: $(project) + configurationToPack: ${{ parameters.buildConfiguration }} + packDirectory: $(dotnetPackagesDir) + verbosityToPack: ${{ parameters.dotnetVerbosity }} + buildProperties: SqlServerPackageVersion=${{ parameters.sqlServerPackageVersion }};BuildNumber=$(Build.BuildNumber);SigningKeyPath=$(driverKeyFile.secureFilePath) + + - ${{ else }}: + - task: DotNetCoreCLI@2 + displayName: Create NuGet Package + inputs: + command: pack + packagesToPack: $(project) + configurationToPack: ${{ parameters.buildConfiguration }} + packDirectory: $(dotnetPackagesDir) + verbosityToPack: ${{ parameters.dotnetVerbosity }} + buildProperties: SqlServerPackageVersion=${{ parameters.sqlServerPackageVersion }};BuildNumber=$(Build.BuildNumber) - task: PublishPipelineArtifact@1 displayName: Publish Pipeline Artifact diff --git a/eng/pipelines/onebranch/jobs/validate-signed-package-job.yml b/eng/pipelines/onebranch/jobs/validate-signed-package-job.yml index afa5aa5918..0769e2093c 100644 --- a/eng/pipelines/onebranch/jobs/validate-signed-package-job.yml +++ b/eng/pipelines/onebranch/jobs/validate-signed-package-job.yml @@ -157,8 +157,8 @@ jobs: $nugetPackageInstallPath = "${{ variables.nugetPackageInstallPath }}" echo "nugetPackageInstallPath= $nugetPackageInstallPath" - # Verify strong name signing ##################################### - echo "> 1. Verifying strong name signing of DLLs ..." + # Verify strong-name signing ################################### + echo "> 1. Verifying strong-name signing of DLLs ..." # @TODO: This path seems brittle to VS upgrades, can we make it more flexible? $snPath = "C:\Program Files (x86)\Microsoft SDKs\Windows\*\bin\NETFX 4.8.1 Tools\sn.exe" diff --git a/eng/pipelines/onebranch/steps/build-buildproj-step.yml b/eng/pipelines/onebranch/steps/build-buildproj-step.yml index 5cfc809772..83f14aaacc 100644 --- a/eng/pipelines/onebranch/steps/build-buildproj-step.yml +++ b/eng/pipelines/onebranch/steps/build-buildproj-step.yml @@ -57,12 +57,8 @@ parameters: type: string steps: - # Download the strong name signing key from secure file storage - - task: DownloadSecureFile@1 - displayName: 'Download Signing Key' - inputs: - secureFile: 'netfxKeypair.snk' - name: keyFile + # Download the assembly signing key from secure file storage. + - template: /eng/pipelines/common/steps/download-assembly-signing-key.yml@self - task: DotNetCoreCLI@2 displayName: 'build.proj - Build${{ parameters.packageShortName }}' @@ -74,7 +70,7 @@ steps: -p:Configuration=${{ parameters.buildConfiguration }} -p:ReferenceType=Package -p:SkipDependencyPack=true - -p:SigningKeyPath="$(keyFile.secureFilePath)" + -p:SigningKeyPath="$(driverKeyFile.secureFilePath)" -p:BuildNumber="${{ parameters.revision }}" -p:PackageVersion${{ parameters.versionPropertySuffix }}="${{ parameters.packageVersion }}" ${{ parameters.dependencyArguments }} diff --git a/eng/pipelines/stages/build-sqlserver-package-ci-stage.yml b/eng/pipelines/stages/build-sqlserver-package-ci-stage.yml index 3a1417185d..66fe07cf36 100644 --- a/eng/pipelines/stages/build-sqlserver-package-ci-stage.yml +++ b/eng/pipelines/stages/build-sqlserver-package-ci-stage.yml @@ -59,6 +59,21 @@ parameters: - detailed - diagnostic + # The C# project reference type to use when building and packing the packages. + - name: referenceType + type: string + default: Project + values: + # Reference sibling packages as NuGet packages. + - Package + # Reference sibling packages as C# projects. + - Project + + # True when building on the internal ADO.Net project. + - name: isInternalBuild + type: boolean + default: false + stages: - stage: build_sqlserver_package_stage @@ -83,3 +98,5 @@ stages: # The version is computed by this stage (see the sqlServerPackageVersion variable above). sqlServerPackageVersion: $(sqlServerPackageVersion) dotnetVerbosity: ${{ parameters.dotnetVerbosity }} + referenceType: ${{ parameters.referenceType }} + isInternalBuild: ${{ parameters.isInternalBuild }} From 98a4e2ab7440c87a1aca597120ebdfae24274d23 Mon Sep 17 00:00:00 2001 From: Paul Medynski <31868385+paulmedynski@users.noreply.github.com> Date: Fri, 21 Aug 2026 11:13:53 -0300 Subject: [PATCH 2/3] Add assembly signing for Microsoft.Data.SqlClient.Internal.Logging Thread referenceType and isInternalBuild into the Logging stage and pack job so the Logging package is strong-name signed on internal Package-mode builds. Abstractions references Logging, so Logging must be signed before Abstractions can be; a strong-named assembly referencing a weak-named one fails with CS8002, which is an error here because TreatWarningsAsErrors is enabled. Logging has no test project yet, so no test-assembly signing or signed InternalsVisibleTo grant is added. --- eng/pipelines/dotnet-sqlclient-ci-core.yml | 2 + .../jobs/pack-logging-package-ci-job.yml | 58 ++++++++++++++----- .../stages/build-logging-package-ci-stage.yml | 17 ++++++ 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/eng/pipelines/dotnet-sqlclient-ci-core.yml b/eng/pipelines/dotnet-sqlclient-ci-core.yml index 2f42bf6e41..36bb1dda1f 100644 --- a/eng/pipelines/dotnet-sqlclient-ci-core.yml +++ b/eng/pipelines/dotnet-sqlclient-ci-core.yml @@ -167,6 +167,8 @@ stages: buildConfiguration: ${{ parameters.buildConfiguration }} debug: ${{ parameters.debug }} dotnetVerbosity: ${{ parameters.dotnetVerbosity }} + referenceType: ${{ parameters.referenceType }} + isInternalBuild: ${{ parameters.isInternalBuild }} # Build the Abstractions package, and publish it to the pipeline artifacts # under the given artifact name. diff --git a/eng/pipelines/jobs/pack-logging-package-ci-job.yml b/eng/pipelines/jobs/pack-logging-package-ci-job.yml index 0f0faa1859..5affd5087b 100644 --- a/eng/pipelines/jobs/pack-logging-package-ci-job.yml +++ b/eng/pipelines/jobs/pack-logging-package-ci-job.yml @@ -50,6 +50,21 @@ parameters: - detailed - diagnostic + # The C# project reference type to use when building and packing the packages. + - name: referenceType + type: string + default: Project + values: + # Reference sibling packages as NuGet packages. + - Package + # Reference sibling packages as C# projects. + - Project + + # True when building on the internal ADO.Net project. + - name: isInternalBuild + type: boolean + default: false + jobs: - job: pack_logging_package_job @@ -95,20 +110,37 @@ jobs: parameters: debug: ${{ parameters.debug }} + # Download the assembly signing key for internal Package-mode builds. + - ${{ if and(eq(parameters.isInternalBuild, true), ne(parameters.referenceType, 'Project')) }}: + - template: /eng/pipelines/common/steps/download-assembly-signing-key.yml@self + # Create the NuGet packages. - - task: DotNetCoreCLI@2 - displayName: Create NuGet Package - inputs: - command: pack - packagesToPack: $(project) - configurationToPack: ${{ parameters.buildConfiguration }} - packDirectory: $(dotnetPackagesDir) - verbosityToPack: ${{ parameters.dotnetVerbosity }} - # BuildNumber supplies the revision component of FileVersion - # (Major.Minor.Patch.Revision). Without it, FileVersionBuildNumber - # defaults to 0 and the assembly is stamped Major.Minor.Patch.0, - # inconsistent with the MDS/AKV packages that pass it. - buildProperties: SqlClientPackageVersion=${{ parameters.packageVersion }};BuildNumber=$(Build.BuildNumber) + # + # BuildNumber supplies the revision component of FileVersion + # (Major.Minor.Patch.Revision). Without it, FileVersionBuildNumber + # defaults to 0 and the assembly is stamped Major.Minor.Patch.0, + # inconsistent with the MDS/AKV packages that pass it. + - ${{ if and(eq(parameters.isInternalBuild, true), ne(parameters.referenceType, 'Project')) }}: + - task: DotNetCoreCLI@2 + displayName: Create NuGet Package + inputs: + command: pack + packagesToPack: $(project) + configurationToPack: ${{ parameters.buildConfiguration }} + packDirectory: $(dotnetPackagesDir) + verbosityToPack: ${{ parameters.dotnetVerbosity }} + buildProperties: SqlClientPackageVersion=${{ parameters.packageVersion }};BuildNumber=$(Build.BuildNumber);SigningKeyPath=$(driverKeyFile.secureFilePath) + + - ${{ else }}: + - task: DotNetCoreCLI@2 + displayName: Create NuGet Package + inputs: + command: pack + packagesToPack: $(project) + configurationToPack: ${{ parameters.buildConfiguration }} + packDirectory: $(dotnetPackagesDir) + verbosityToPack: ${{ parameters.dotnetVerbosity }} + buildProperties: SqlClientPackageVersion=${{ parameters.packageVersion }};BuildNumber=$(Build.BuildNumber) # Publish the NuGet packages as a named pipeline artifact. - task: PublishPipelineArtifact@1 diff --git a/eng/pipelines/stages/build-logging-package-ci-stage.yml b/eng/pipelines/stages/build-logging-package-ci-stage.yml index b9d5feb082..588fb3a17b 100644 --- a/eng/pipelines/stages/build-logging-package-ci-stage.yml +++ b/eng/pipelines/stages/build-logging-package-ci-stage.yml @@ -59,6 +59,21 @@ parameters: - detailed - diagnostic + # The C# project reference type to use when building and packing the packages. + - name: referenceType + type: string + default: Project + values: + # Reference sibling packages as NuGet packages. + - Package + # Reference sibling packages as C# projects. + - Project + + # True when building on the internal ADO.Net project. + - name: isInternalBuild + type: boolean + default: false + stages: - stage: build_logging_package_stage @@ -90,3 +105,5 @@ stages: buildConfiguration: ${{ parameters.buildConfiguration }} debug: ${{ parameters.debug }} dotnetVerbosity: ${{ parameters.dotnetVerbosity }} + referenceType: ${{ parameters.referenceType }} + isInternalBuild: ${{ parameters.isInternalBuild }} From 73cd48a3d2f0d4b564990f5223dc6a4078c34f1d Mon Sep 17 00:00:00 2001 From: Paul Medynski <31868385+paulmedynski@users.noreply.github.com> Date: Fri, 21 Aug 2026 11:25:50 -0300 Subject: [PATCH 3/3] Add assembly signing for Microsoft.Data.SqlClient.Extensions.Abstractions Sign the Abstractions package and its test assembly on internal Package-mode builds, and make the Abstractions CI jobs actually honour Package mode. - Thread isInternalBuild through the Abstractions stage into the pack and test jobs, downloading the driver and test signing keys as needed. - Add a signed InternalsVisibleTo grant for the test assembly, and sign the test assembly when a test key is supplied. - Pass packageVersion, loggingArtifactsName and referenceType into the test jobs, and download the Logging artifacts, so Package mode is exercised. - Correct the pack job to use the canonical SqlClientPackageVersion and BuildNumber properties instead of undeclared per-package parameters. - Thread signing and reference-type arguments into the build.proj TestAbstractions target. - Build the Abstractions test project for net462 only on Windows hosts. --- build.proj | 14 ++-- eng/pipelines/dotnet-sqlclient-ci-core.yml | 1 + .../jobs/pack-abstractions-package-ci-job.yml | 34 ++++++---- .../jobs/test-abstractions-package-ci-job.yml | 67 +++++++++++++++++-- .../build-abstractions-package-ci-stage.yml | 18 +++++ .../Abstractions/src/Abstractions.csproj | 12 ++++ .../test/Abstractions.Test.csproj | 16 ++++- 7 files changed, 138 insertions(+), 24 deletions(-) diff --git a/build.proj b/build.proj index 9883656f50..c7c70e9e5b 100644 --- a/build.proj +++ b/build.proj @@ -884,22 +884,28 @@ - AbstractionsTests-$(OS) $(LogFilePrefix)-$(TestFramework) "$(DotnetPath)dotnet" test "$(AbstractionsTestProjectPath)" + + -p:Configuration=$(Configuration) + $(SigningKeyPathArgument) + $(TestSigningKeyPathArgument) + + $(TestBlameArgument) $(TestCodeCoverageArgument) $(TestFiltersArgument) $(TestFrameworkArgument) --results-directory "$(TestResultsFolderPath)" --logger:"trx;LogFilePrefix=$(LogFilePrefix)" + + + $(ReferenceTypeArgument) + $(PackageVersionSqlClientArgument) $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s+", " ")) diff --git a/eng/pipelines/dotnet-sqlclient-ci-core.yml b/eng/pipelines/dotnet-sqlclient-ci-core.yml index 36bb1dda1f..1ce914db02 100644 --- a/eng/pipelines/dotnet-sqlclient-ci-core.yml +++ b/eng/pipelines/dotnet-sqlclient-ci-core.yml @@ -183,6 +183,7 @@ stages: dotnetVerbosity: ${{ parameters.dotnetVerbosity }} loggingArtifactsName: $(loggingArtifactsName) referenceType: ${{ parameters.referenceType }} + isInternalBuild: ${{ parameters.isInternalBuild }} # When building Abstractions via packages, we must depend on the Logging # package. ${{ if eq(parameters.referenceType, 'Package') }}: diff --git a/eng/pipelines/jobs/pack-abstractions-package-ci-job.yml b/eng/pipelines/jobs/pack-abstractions-package-ci-job.yml index 8bf43bd997..6a360e9bad 100644 --- a/eng/pipelines/jobs/pack-abstractions-package-ci-job.yml +++ b/eng/pipelines/jobs/pack-abstractions-package-ci-job.yml @@ -15,7 +15,7 @@ parameters: # The name to apply to the published pipeline artifacts. - name: abstractionsArtifactsName type: string - default: Abstractions.Artifact + default: Abstractions.Artifacts # The version to apply to the Abstractions NuGet package and its assemblies. Every package in the # SqlClient family shares this version. @@ -67,6 +67,11 @@ parameters: # Reference sibling packages as C# projects. - Project + # True when building on the internal ADO.Net project. + - name: isInternalBuild + type: boolean + default: false + jobs: - job: pack_abstractions_package_job @@ -130,12 +135,23 @@ jobs: parameters: debug: ${{ parameters.debug }} + # Download the assembly signing key for internal Package-mode builds. + - ${{ if and(eq(parameters.isInternalBuild, true), ne(parameters.referenceType, 'Project')) }}: + - template: /eng/pipelines/common/steps/download-assembly-signing-key.yml@self + # Create the NuGet packages. - # - # When referenceType is Package, we must pass ReferenceType and the - # dependency version so that Directory.Packages.props applies version - # ranges to sibling package dependencies. - - ${{ if eq(parameters.referenceType, 'Package') }}: + - ${{ if and(eq(parameters.referenceType, 'Package'), eq(parameters.isInternalBuild, true)) }}: + - task: DotNetCoreCLI@2 + displayName: Create NuGet Package + inputs: + command: pack + packagesToPack: $(project) + configurationToPack: ${{ parameters.buildConfiguration }} + packDirectory: $(dotnetPackagesDir) + verbosityToPack: ${{ parameters.dotnetVerbosity }} + buildProperties: SqlClientPackageVersion=${{ parameters.packageVersion }};ReferenceType=Package;BuildNumber=$(Build.BuildNumber);SigningKeyPath=$(driverKeyFile.secureFilePath) + + - ${{ elseif eq(parameters.referenceType, 'Package') }}: - task: DotNetCoreCLI@2 displayName: Create NuGet Package inputs: @@ -144,8 +160,6 @@ jobs: configurationToPack: ${{ parameters.buildConfiguration }} packDirectory: $(dotnetPackagesDir) verbosityToPack: ${{ parameters.dotnetVerbosity }} - # BuildNumber supplies the revision component of FileVersion; without - # it the assembly is stamped Major.Minor.Patch.0 (see Project branch). buildProperties: SqlClientPackageVersion=${{ parameters.packageVersion }};ReferenceType=Package;BuildNumber=$(Build.BuildNumber) - ${{ else }}: @@ -157,10 +171,6 @@ jobs: configurationToPack: ${{ parameters.buildConfiguration }} packDirectory: $(dotnetPackagesDir) verbosityToPack: ${{ parameters.dotnetVerbosity }} - # BuildNumber supplies the revision component of FileVersion - # (Major.Minor.Patch.Revision). Without it, FileVersionBuildNumber - # defaults to 0 and the assembly is stamped Major.Minor.Patch.0, - # inconsistent with the MDS/AKV packages that pass it. buildProperties: SqlClientPackageVersion=${{ parameters.packageVersion }};BuildNumber=$(Build.BuildNumber) # Publish the NuGet packages as a named pipeline artifact. diff --git a/eng/pipelines/jobs/test-abstractions-package-ci-job.yml b/eng/pipelines/jobs/test-abstractions-package-ci-job.yml index 83366b52a9..ad423ab807 100644 --- a/eng/pipelines/jobs/test-abstractions-package-ci-job.yml +++ b/eng/pipelines/jobs/test-abstractions-package-ci-job.yml @@ -13,6 +13,18 @@ parameters: + # The name of the Logging pipeline artifacts to download. + # + # This is used when the referenceType is 'Package'. + - name: loggingArtifactsName + type: string + default: Logging.Artifacts + + # The version to apply to the SqlClient family packages. This is used when + # referenceType is 'Package'. + - name: packageVersion + type: string + # The type of build to test (Release or Debug) - name: buildConfiguration type: string @@ -61,6 +73,20 @@ parameters: - name: poolName type: string + # True when building on the internal ADO.Net project. When set, assemblies + # are signed with the driver key and tests are signed with the test key. + - name: isInternalBuild + type: boolean + default: false + + # The C# project reference type to use when building. + - name: referenceType + type: string + default: Project + values: + - Package + - Project + # The pool VM image to use. - name: vmImage type: string @@ -88,12 +114,24 @@ jobs: - name: project value: src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/Abstractions.Test.csproj - # dotnet CLI arguments for build/test/pack commands - - name: buildArguments + # dotnet CLI arguments for build/test commands. + - name: dotnetBuildOpts value: >- -p:Configuration=${{ parameters.buildConfiguration }} + -p:ReferenceType=${{ parameters.referenceType }} + -p:SqlClientPackageVersion=${{ parameters.packageVersion }} --verbosity ${{ parameters.dotnetVerbosity }} + # Signing arguments — only set for internal Package-mode builds. + - ${{ if and(eq(parameters.isInternalBuild, true), ne(parameters.referenceType, 'Project')) }}: + - name: signingArguments + value: >- + -p:SigningKeyPath=$(driverKeyFile.secureFilePath) + -p:TestSigningKeyPath=$(testKeyFile.secureFilePath) + - ${{ else }}: + - name: signingArguments + value: '' + # Explicitly unset the $PLATFORM environment variable that is set by the # 'ADO Build properties' Library in the ADO SqlClientDrivers public project. # This is defined with a non-standard Platform of 'AnyCPU', and will fail @@ -121,6 +159,21 @@ jobs: - pwsh: 'Get-ChildItem Env: | Sort-Object Name' displayName: '[Debug] Print Environment Variables' + # Download the assembly signing keys for internal Package-mode builds. + - ${{ if and(eq(parameters.isInternalBuild, true), ne(parameters.referenceType, 'Project')) }}: + - template: /eng/pipelines/common/steps/download-assembly-signing-key.yml@self + - template: /eng/pipelines/common/steps/download-assembly-signing-key.yml@self + parameters: + isTest: true + + # For Package reference builds, download the Logging dependency into packages/. + - ${{ if eq(parameters.referenceType, 'Package') }}: + - task: DownloadPipelineArtifact@2 + displayName: Download Logging Package Artifacts + inputs: + artifactName: ${{ parameters.loggingArtifactsName }} + targetPath: $(Build.SourcesDirectory)/packages + # Install the .NET SDK and Runtimes. - template: /eng/pipelines/common/steps/install-dotnet.yml@self parameters: @@ -136,7 +189,7 @@ jobs: inputs: command: build projects: $(project) - arguments: $(buildArguments) + arguments: $(dotnetBuildOpts) $(signingArguments) # Run the tests for each .NET runtime. - ${{ each runtime in parameters.netRuntimes }}: @@ -146,7 +199,7 @@ jobs: command: test projects: $(project) arguments: >- - $(buildArguments) + $(dotnetBuildOpts) --no-build -f ${{ runtime }} --filter "category != failing & category != flaky & category != interactive" @@ -157,7 +210,7 @@ jobs: command: test projects: $(project) arguments: >- - $(buildArguments) + $(dotnetBuildOpts) --no-build -f ${{ runtime }} --filter "category = flaky" @@ -170,7 +223,7 @@ jobs: command: test projects: $(project) arguments: >- - $(buildArguments) + $(dotnetBuildOpts) --no-build -f ${{ runtime }} --filter "category != failing & category != flaky & category != interactive" @@ -181,7 +234,7 @@ jobs: command: test projects: $(project) arguments: >- - $(buildArguments) + $(dotnetBuildOpts) --no-build -f ${{ runtime }} --filter "category = flaky" diff --git a/eng/pipelines/stages/build-abstractions-package-ci-stage.yml b/eng/pipelines/stages/build-abstractions-package-ci-stage.yml index 3df0ef9843..b15edb29d3 100644 --- a/eng/pipelines/stages/build-abstractions-package-ci-stage.yml +++ b/eng/pipelines/stages/build-abstractions-package-ci-stage.yml @@ -76,6 +76,11 @@ parameters: # Reference sibling packages as C# projects. - Project + # True when building on the internal ADO.Net project. + - name: isInternalBuild + type: boolean + default: false + stages: - stage: build_abstractions_package_stage @@ -98,14 +103,18 @@ stages: - template: /eng/pipelines/jobs/test-abstractions-package-ci-job.yml@self parameters: + packageVersion: $(packageVersion) buildConfiguration: ${{ parameters.buildConfiguration }} debug: ${{ parameters.debug }} displayNamePrefix: Linux dotnetVerbosity: ${{ parameters.dotnetVerbosity }} + isInternalBuild: ${{ parameters.isInternalBuild }} jobNameSuffix: linux + loggingArtifactsName: ${{ parameters.loggingArtifactsName }} netFrameworkRuntimes: [] netRuntimes: [net8.0, net9.0, net10.0] poolName: Azure Pipelines + referenceType: ${{ parameters.referenceType }} vmImage: ubuntu-latest # ------------------------------------------------------------------------ @@ -113,14 +122,18 @@ stages: - template: /eng/pipelines/jobs/test-abstractions-package-ci-job.yml@self parameters: + packageVersion: $(packageVersion) buildConfiguration: ${{ parameters.buildConfiguration }} debug: ${{ parameters.debug }} displayNamePrefix: Win dotnetVerbosity: ${{ parameters.dotnetVerbosity }} + isInternalBuild: ${{ parameters.isInternalBuild }} jobNameSuffix: windows + loggingArtifactsName: ${{ parameters.loggingArtifactsName }} netFrameworkRuntimes: [net462] netRuntimes: [net8.0, net9.0, net10.0] poolName: Azure Pipelines + referenceType: ${{ parameters.referenceType }} vmImage: windows-latest # ------------------------------------------------------------------------ @@ -128,14 +141,18 @@ stages: - template: /eng/pipelines/jobs/test-abstractions-package-ci-job.yml@self parameters: + packageVersion: $(packageVersion) buildConfiguration: ${{ parameters.buildConfiguration }} debug: ${{ parameters.debug }} displayNamePrefix: macOS dotnetVerbosity: ${{ parameters.dotnetVerbosity }} + isInternalBuild: ${{ parameters.isInternalBuild }} jobNameSuffix: macos + loggingArtifactsName: ${{ parameters.loggingArtifactsName }} netFrameworkRuntimes: [] netRuntimes: [net8.0, net9.0, net10.0] poolName: Azure Pipelines + referenceType: ${{ parameters.referenceType }} vmImage: macos-latest # ------------------------------------------------------------------------ @@ -157,3 +174,4 @@ stages: dotnetVerbosity: ${{ parameters.dotnetVerbosity }} loggingArtifactsName: ${{ parameters.loggingArtifactsName }} referenceType: ${{ parameters.referenceType }} + isInternalBuild: ${{ parameters.isInternalBuild }} diff --git a/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/Abstractions.csproj b/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/Abstractions.csproj index e8b3c55ba0..8826080981 100644 --- a/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/Abstractions.csproj +++ b/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/Abstractions.csproj @@ -33,10 +33,22 @@ + + + + + + + $(RepoRoot)artifacts/ diff --git a/src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/Abstractions.Test.csproj b/src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/Abstractions.Test.csproj index 427a7aaf9f..8a80c24a51 100644 --- a/src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/Abstractions.Test.csproj +++ b/src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/Abstractions.Test.csproj @@ -2,12 +2,26 @@ Microsoft.Data.SqlClient.Extensions.Abstractions.Test - net462;net8.0;net9.0;net10.0 + net8.0;net9.0;net10.0 + + + $(TargetFrameworks);net462 false true + + + + true + $(TestSigningKeyPath) + + enable