From fff2d40d96cda6eab87cf9d9ad1619f25f42dfad Mon Sep 17 00:00:00 2001
From: Paul Medynski <31868385+paulmedynski@users.noreply.github.com>
Date: Thu, 11 Jun 2026 11:09:38 -0300
Subject: [PATCH 1/3] Use upper-bound version ranges for sibling package
dependencies
Compute [floor, ceiling) version ranges for all sibling package dependencies
(Abstractions, Logging, MDS, Azure, AKV, SNI, SqlServer.Server) so that NuGet
cannot resolve an incompatible newer major version at restore time.
Changes:
- Define range properties in tools/props/Versions.props (available to both
build.proj and SDK-style projects via Directory.Build.props import order)
- Reference range properties in Directory.Packages.props PackageVersion items
- Update Microsoft.Data.SqlClient.nuspec to use range tokens
- Pass range properties through GenerateMdsPackage.targets to nuget pack
- Replace MSBuild@1 with DotNetCoreCLI@2 for MDS pack in CI and OneBranch
- Wire loggingPackageVersion/referenceType through Abstractions and Azure
pipeline stages for Package-mode builds
- Remove unused generate-nuget-package-step.yml template
---
Directory.Packages.props | 30 +++++--
.../templates/jobs/ci-build-nugets-job.yml | 27 ++++---
.../steps/generate-nuget-package-step.yml | 80 -------------------
eng/pipelines/dotnet-sqlclient-ci-core.yml | 5 ++
.../jobs/pack-abstractions-package-ci-job.yml | 67 +++++++++++++---
.../jobs/pack-azure-package-ci-job.yml | 43 +++++++---
.../build-signed-sqlclient-package-job.yml | 28 ++++---
.../build-abstractions-package-ci-stage.yml | 27 +++++++
.../stages/build-azure-package-ci-stage.yml | 16 ++++
src/Microsoft.Data.SqlClient.sln | 1 -
tools/props/Versions.props | 25 ++++++
tools/specs/Microsoft.Data.SqlClient.nuspec | 37 ++++-----
tools/targets/GenerateMdsPackage.targets | 7 +-
13 files changed, 243 insertions(+), 150 deletions(-)
delete mode 100644 eng/pipelines/common/templates/steps/generate-nuget-package-step.yml
diff --git a/Directory.Packages.props b/Directory.Packages.props
index b1a858bf72..4baf8cbfec 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -14,6 +14,20 @@
+
+
@@ -21,7 +35,7 @@
We never reference this package via its project, so we always need a
version specified.
-->
-
+
@@ -89,8 +103,8 @@
-
-
+
+
diff --git a/eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml b/eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml
index 5e17b506c1..130c361e50 100644
--- a/eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml
+++ b/eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml
@@ -143,16 +143,23 @@ jobs:
abstractionsPackageVersion: ${{parameters.abstractionsPackageVersion}}
loggingPackageVersion: ${{ parameters.loggingPackageVersion }}
- - template: /eng/pipelines/common/templates/steps/generate-nuget-package-step.yml@self
- parameters:
- buildConfiguration: ${{ parameters.buildConfiguration }}
- displayName: 'Create MDS NuGet Package'
- generateSymbolsPackage: true
- nuspecPath: 'tools/specs/Microsoft.Data.SqlClient.nuspec'
- outputDirectory: $(packagePath)
- packageVersion: ${{ parameters.mdsPackageVersion }}
- properties: 'AbstractionsPackageVersion=${{ parameters.abstractionsPackageVersion }};LoggingPackageVersion=${{ parameters.loggingPackageVersion }}'
- referenceType: ${{ parameters.referenceType }}
+ # Create the MDS NuGet package via build.proj's GenerateMdsPackage target.
+ # This target has access to the version range properties computed in
+ # Versions.props, so it passes them through to nuget pack automatically.
+ - task: DotNetCoreCLI@2
+ displayName: 'Create MDS NuGet Package'
+ inputs:
+ command: build
+ projects: build.proj
+ arguments: >-
+ -t:GenerateMdsPackage
+ -p:GenerateNuget=true
+ -p:Configuration=${{ parameters.buildConfiguration }}
+ -p:ReferenceType=${{ parameters.referenceType }}
+ -p:MdsPackageVersion=${{ parameters.mdsPackageVersion }}
+ -p:AbstractionsPackageVersion=${{ parameters.abstractionsPackageVersion }}
+ -p:LoggingPackageVersion=${{ parameters.loggingPackageVersion }}
+ -p:PackagesDir=$(packagePath)
# When building in Package mode, the AKV Provider restore needs to find the MDS package
# we just built. Copy it to the local NuGet feed so NuGet.config can resolve it.
diff --git a/eng/pipelines/common/templates/steps/generate-nuget-package-step.yml b/eng/pipelines/common/templates/steps/generate-nuget-package-step.yml
deleted file mode 100644
index 46c5c61492..0000000000
--- a/eng/pipelines/common/templates/steps/generate-nuget-package-step.yml
+++ /dev/null
@@ -1,80 +0,0 @@
-#################################################################################
-# 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. #
-#################################################################################
-parameters:
- - name: nuspecPath
- type: string
-
- - name: packageVersion
- type: string
-
- - name: outputDirectory
- type: string
- default: '$(Build.SourcesDirectory)/output'
-
- # The C# build configuration (e.g. Debug or Release) to use when building the NuGet package.
- - name: buildConfiguration
- type: string
- default: Debug
- values:
- - Debug
- - Release
-
- - name: generateSymbolsPackage
- type: boolean
-
- - name: displayName
- type: string
-
- - name: installNuget
- type: boolean
- default: true
-
- # The C# project reference type to use when building and packing the packages.
- - name: referenceType
- type: string
- values:
- # Reference sibling packages as NuGet packages.
- - Package
- # Reference sibling packages as C# projects.
- - Project
-
- # Semi-colon separated properties to pass to nuget pack via the -properties argument.
- - name: properties
- type: string
- default: ''
-
-steps:
-- ${{ if parameters.installNuget }}:
- - task: NuGetToolInstaller@1
- displayName: 'Install Latest Nuget'
- inputs:
- checkLatest: true
-
-- powershell: |
- $Commit=git rev-parse HEAD
- Write-Host "##vso[task.setvariable variable=CommitHead;]$Commit"
- displayName: CommitHead
-
-- task: NuGetCommand@2
- displayName: ${{parameters.displayName }}
- inputs:
- command: custom
- ${{ if parameters.generateSymbolsPackage }}:
- arguments: >-
- pack
- -Symbols
- -SymbolPackageFormat snupkg
- ${{parameters.nuspecPath}}
- -Version ${{parameters.packageVersion}}
- -OutputDirectory ${{parameters.outputDirectory}}
- -properties "COMMITID=$(CommitHead);Configuration=${{parameters.buildConfiguration}};ReferenceType=${{parameters.referenceType}};${{parameters.properties}}"
- ${{else }}:
- arguments: >-
- pack
- ${{parameters.nuspecPath}}
- -Version ${{parameters.packageVersion}}
- -OutputDirectory ${{parameters.outputDirectory}}
- -properties "COMMITID=$(CommitHead);Configuration=${{parameters.buildConfiguration}};ReferenceType=${{parameters.referenceType}};${{parameters.properties}}"
diff --git a/eng/pipelines/dotnet-sqlclient-ci-core.yml b/eng/pipelines/dotnet-sqlclient-ci-core.yml
index f9ead686ff..7cedad97f6 100644
--- a/eng/pipelines/dotnet-sqlclient-ci-core.yml
+++ b/eng/pipelines/dotnet-sqlclient-ci-core.yml
@@ -149,6 +149,9 @@ stages:
buildConfiguration: ${{ parameters.buildConfiguration }}
debug: ${{ parameters.debug }}
dotnetVerbosity: ${{ parameters.dotnetVerbosity }}
+ loggingArtifactsName: $(loggingArtifactsName)
+ loggingPackageVersion: $(loggingPackageVersion)
+ referenceType: ${{ parameters.referenceType }}
# When building Abstractions via packages, we must depend on the Logging
# package.
${{ if eq(parameters.referenceType, 'Package') }}:
@@ -198,6 +201,8 @@ stages:
- build_logging_package_stage
- build_sqlclient_package_stage
dotnetVerbosity: ${{ parameters.dotnetVerbosity }}
+ loggingArtifactsName: $(loggingArtifactsName)
+ loggingPackageVersion: $(loggingPackageVersion)
mdsArtifactsName: $(mdsArtifactsName)
mdsPackageVersion: $(mdsPackageVersion)
referenceType: ${{ parameters.referenceType }}
diff --git a/eng/pipelines/jobs/pack-abstractions-package-ci-job.yml b/eng/pipelines/jobs/pack-abstractions-package-ci-job.yml
index 9db1c05696..adfe91dd7b 100644
--- a/eng/pipelines/jobs/pack-abstractions-package-ci-job.yml
+++ b/eng/pipelines/jobs/pack-abstractions-package-ci-job.yml
@@ -53,6 +53,30 @@ parameters:
- detailed
- diagnostic
+ # 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 Logging package version to depend on.
+ #
+ # This is used when the referenceType is 'Package'.
+ - name: loggingPackageVersion
+ type: string
+ default: ''
+
+ # 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
+
jobs:
- job: pack_abstractions_package_job
@@ -104,21 +128,46 @@ jobs:
- pwsh: 'Get-ChildItem Env: | Sort-Object Name'
displayName: '[Debug] Print Environment Variables'
+ # For Package reference builds, we must first download the dependency
+ # package artifacts.
+ - ${{ 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.
- template: /eng/pipelines/steps/install-dotnet.yml@self
parameters:
debug: ${{ parameters.debug }}
# Create the NuGet packages.
- - task: DotNetCoreCLI@2
- displayName: Create NuGet Package
- inputs:
- command: pack
- packagesToPack: $(project)
- configurationToPack: ${{ parameters.buildConfiguration }}
- packDirectory: $(dotnetPackagesDir)
- verbosityToPack: ${{ parameters.dotnetVerbosity }}
- buildProperties: AbstractionsPackageVersion=${{ parameters.abstractionsPackageVersion }};AbstractionsAssemblyFileVersion=${{ parameters.abstractionsAssemblyFileVersion }}
+ #
+ # 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') }}:
+ - task: DotNetCoreCLI@2
+ displayName: Create NuGet Package
+ inputs:
+ command: pack
+ packagesToPack: $(project)
+ configurationToPack: ${{ parameters.buildConfiguration }}
+ packDirectory: $(dotnetPackagesDir)
+ verbosityToPack: ${{ parameters.dotnetVerbosity }}
+ buildProperties: AbstractionsPackageVersion=${{ parameters.abstractionsPackageVersion }};AbstractionsAssemblyFileVersion=${{ parameters.abstractionsAssemblyFileVersion }};ReferenceType=Package;LoggingPackageVersion=${{ parameters.loggingPackageVersion }}
+
+ - ${{ else }}:
+ - task: DotNetCoreCLI@2
+ displayName: Create NuGet Package
+ inputs:
+ command: pack
+ packagesToPack: $(project)
+ configurationToPack: ${{ parameters.buildConfiguration }}
+ packDirectory: $(dotnetPackagesDir)
+ verbosityToPack: ${{ parameters.dotnetVerbosity }}
+ buildProperties: AbstractionsPackageVersion=${{ parameters.abstractionsPackageVersion }};AbstractionsAssemblyFileVersion=${{ parameters.abstractionsAssemblyFileVersion }}
# Publish the NuGet packages as a named pipeline artifact.
- task: PublishPipelineArtifact@1
diff --git a/eng/pipelines/jobs/pack-azure-package-ci-job.yml b/eng/pipelines/jobs/pack-azure-package-ci-job.yml
index 95853d43e0..4afa8ceaae 100644
--- a/eng/pipelines/jobs/pack-azure-package-ci-job.yml
+++ b/eng/pipelines/jobs/pack-azure-package-ci-job.yml
@@ -26,12 +26,19 @@ parameters:
type: string
default: Logging.Artifacts
- # The Abstractions package verion to depend on.
+ # The Abstractions package version to depend on.
#
# This is used when the referenceType is 'Package'.
- name: abstractionsPackageVersion
type: string
+ # The Logging package version to depend on.
+ #
+ # This is used when the referenceType is 'Package'.
+ - name: loggingPackageVersion
+ type: string
+ default: ''
+
# The name of the pipeline artifacts to publish.
- name: azureArtifactsName
type: string
@@ -153,15 +160,31 @@ jobs:
debug: ${{ parameters.debug }}
# Create the NuGet packages.
- - task: DotNetCoreCLI@2
- displayName: Create NuGet Package
- inputs:
- command: pack
- packagesToPack: $(project)
- configurationToPack: ${{ parameters.buildConfiguration }}
- packDirectory: $(dotnetPackagesDir)
- verbosityToPack: ${{ parameters.dotnetVerbosity }}
- buildProperties: AzurePackageVersion=${{ parameters.azurePackageVersion }};AzureAssemblyFileVersion=${{ parameters.azureAssemblyFileVersion }}
+ #
+ # When referenceType is Package, we must pass ReferenceType and the
+ # dependency versions so that Directory.Packages.props applies version
+ # ranges to sibling package dependencies.
+ - ${{ if eq(parameters.referenceType, 'Package') }}:
+ - task: DotNetCoreCLI@2
+ displayName: Create NuGet Package
+ inputs:
+ command: pack
+ packagesToPack: $(project)
+ configurationToPack: ${{ parameters.buildConfiguration }}
+ packDirectory: $(dotnetPackagesDir)
+ verbosityToPack: ${{ parameters.dotnetVerbosity }}
+ buildProperties: AzurePackageVersion=${{ parameters.azurePackageVersion }};AzureAssemblyFileVersion=${{ parameters.azureAssemblyFileVersion }};ReferenceType=Package;LoggingPackageVersion=${{ parameters.loggingPackageVersion }};AbstractionsPackageVersion=${{ parameters.abstractionsPackageVersion }}
+
+ - ${{ else }}:
+ - task: DotNetCoreCLI@2
+ displayName: Create NuGet Package
+ inputs:
+ command: pack
+ packagesToPack: $(project)
+ configurationToPack: ${{ parameters.buildConfiguration }}
+ packDirectory: $(dotnetPackagesDir)
+ verbosityToPack: ${{ parameters.dotnetVerbosity }}
+ buildProperties: AzurePackageVersion=${{ parameters.azurePackageVersion }};AzureAssemblyFileVersion=${{ parameters.azureAssemblyFileVersion }}
# Publish the NuGet packages as a named pipeline artifact.
- task: PublishPipelineArtifact@1
diff --git a/eng/pipelines/onebranch/jobs/build-signed-sqlclient-package-job.yml b/eng/pipelines/onebranch/jobs/build-signed-sqlclient-package-job.yml
index 98f5c811aa..bd5cd9d271 100644
--- a/eng/pipelines/onebranch/jobs/build-signed-sqlclient-package-job.yml
+++ b/eng/pipelines/onebranch/jobs/build-signed-sqlclient-package-job.yml
@@ -93,17 +93,23 @@ jobs:
sourceRoot: $(BUILD_OUTPUT)
dllPattern: 'Microsoft.Data.SqlClient.resources.dll'
- - template: /eng/pipelines/common/templates/steps/generate-nuget-package-step.yml@self
- parameters:
- buildConfiguration: Release
- displayName: 'Create MDS NuGet Package'
- generateSymbolsPackage: true
- installNuget: false
- nuspecPath: $(nuspecPath)
- outputDirectory: $(PACK_OUTPUT)
- packageVersion: $(mdsPackageVersion)
- properties: 'AbstractionsPackageVersion=$(abstractionsPackageVersion);LoggingPackageVersion=$(loggingPackageVersion)'
- referenceType: Package
+ # Create the MDS NuGet package via build.proj's GenerateMdsPackage target.
+ # This target has access to the version range properties computed in
+ # Versions.props, so it passes them through to nuget pack automatically.
+ - task: DotNetCoreCLI@2
+ displayName: 'Create MDS NuGet Package'
+ inputs:
+ command: build
+ projects: $(REPO_ROOT)/build.proj
+ arguments: >-
+ -t:GenerateMdsPackage
+ -p:GenerateNuget=true
+ -p:Configuration=Release
+ -p:ReferenceType=Package
+ -p:MdsPackageVersion=$(mdsPackageVersion)
+ -p:AbstractionsPackageVersion=$(abstractionsPackageVersion)
+ -p:LoggingPackageVersion=$(loggingPackageVersion)
+ -p:PackagesDir=$(PACK_OUTPUT)
- template: /eng/pipelines/onebranch/steps/esrp-code-signing-step.yml@self
parameters:
diff --git a/eng/pipelines/stages/build-abstractions-package-ci-stage.yml b/eng/pipelines/stages/build-abstractions-package-ci-stage.yml
index 6aae1703b8..8579b79caf 100644
--- a/eng/pipelines/stages/build-abstractions-package-ci-stage.yml
+++ b/eng/pipelines/stages/build-abstractions-package-ci-stage.yml
@@ -67,6 +67,30 @@ parameters:
- detailed
- diagnostic
+ # 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 Logging package version to depend on.
+ #
+ # This is used when the referenceType is 'Package'.
+ - name: loggingPackageVersion
+ type: string
+ default: ''
+
+ # 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
+
stages:
- stage: build_abstractions_package_stage
@@ -141,3 +165,6 @@ stages:
- test_abstractions_package_job_windows
- test_abstractions_package_job_macos
dotnetVerbosity: ${{ parameters.dotnetVerbosity }}
+ loggingArtifactsName: ${{ parameters.loggingArtifactsName }}
+ loggingPackageVersion: ${{ parameters.loggingPackageVersion }}
+ referenceType: ${{ parameters.referenceType }}
diff --git a/eng/pipelines/stages/build-azure-package-ci-stage.yml b/eng/pipelines/stages/build-azure-package-ci-stage.yml
index 3b57ce8c3b..36d754b15f 100644
--- a/eng/pipelines/stages/build-azure-package-ci-stage.yml
+++ b/eng/pipelines/stages/build-azure-package-ci-stage.yml
@@ -101,6 +101,20 @@ parameters:
- detailed
- diagnostic
+ # 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 Logging package version to depend on.
+ #
+ # This is used when the referenceType is 'Package'.
+ - name: loggingPackageVersion
+ type: string
+ default: ''
+
# The name of the MDS pipeline artifacts to download.
#
# This is used when the referenceType is 'Package'.
@@ -282,4 +296,6 @@ stages:
- test_azure_package_job_windows_integration
- test_azure_package_job_macos
dotnetVerbosity: ${{ parameters.dotnetVerbosity }}
+ loggingArtifactsName: ${{ parameters.loggingArtifactsName }}
+ loggingPackageVersion: ${{ parameters.loggingPackageVersion }}
referenceType: ${{ parameters.referenceType }}
diff --git a/src/Microsoft.Data.SqlClient.sln b/src/Microsoft.Data.SqlClient.sln
index 0a80e8f0ca..74dab217ba 100644
--- a/src/Microsoft.Data.SqlClient.sln
+++ b/src/Microsoft.Data.SqlClient.sln
@@ -262,7 +262,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "steps", "steps", "{EABE3A3E
..\eng\pipelines\common\templates\steps\configure-sql-server-win-step.yml = ..\eng\pipelines\common\templates\steps\configure-sql-server-win-step.yml
..\eng\pipelines\common\templates\steps\copy-dlls-for-test-step.yml = ..\eng\pipelines\common\templates\steps\copy-dlls-for-test-step.yml
..\eng\pipelines\common\templates\steps\esrp-code-signing-step.yml = ..\eng\pipelines\common\templates\steps\esrp-code-signing-step.yml
- ..\eng\pipelines\common\templates\steps\generate-nuget-package-step.yml = ..\eng\pipelines\common\templates\steps\generate-nuget-package-step.yml
..\eng\pipelines\common\templates\steps\override-sni-version.yml = ..\eng\pipelines\common\templates\steps\override-sni-version.yml
..\eng\pipelines\common\templates\steps\pre-build-step.yml = ..\eng\pipelines\common\templates\steps\pre-build-step.yml
..\eng\pipelines\common\templates\steps\prepare-test-db-step.yml = ..\eng\pipelines\common\templates\steps\prepare-test-db-step.yml
diff --git a/tools/props/Versions.props b/tools/props/Versions.props
index 574299da81..1e0262e73d 100644
--- a/tools/props/Versions.props
+++ b/tools/props/Versions.props
@@ -67,4 +67,29 @@
+
+
+
+ 6.0.2
+ [$(SniVersion), $([MSBuild]::Add($(SniVersion.Split('.')[0]), 1)).0.0)
+ [1.0.0, 2.0.0)
+ [$(AbstractionsPackageVersion), $([MSBuild]::Add($(AbstractionsPackageVersion.Trim().Split('.')[0]), 1)).0.0)
+ [$(LoggingPackageVersion), $([MSBuild]::Add($(LoggingPackageVersion.Trim().Split('.')[0]), 1)).0.0)
+ [$(MdsPackageVersion), $([MSBuild]::Add($(MdsPackageVersion.Trim().Split('.')[0]), 1)).0.0)
+ [$(AzurePackageVersion), $([MSBuild]::Add($(AzurePackageVersion.Trim().Split('.')[0]), 1)).0.0)
+ [$(AkvPackageVersion), $([MSBuild]::Add($(AkvPackageVersion.Trim().Split('.')[0]), 1)).0.0)
+
+
diff --git a/tools/specs/Microsoft.Data.SqlClient.nuspec b/tools/specs/Microsoft.Data.SqlClient.nuspec
index 117af2dcb2..426548984b 100644
--- a/tools/specs/Microsoft.Data.SqlClient.nuspec
+++ b/tools/specs/Microsoft.Data.SqlClient.nuspec
@@ -29,17 +29,18 @@
sqlclient microsoft.data.sqlclient
-
-
-
+
+
+
@@ -60,37 +61,37 @@
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
+
diff --git a/tools/targets/GenerateMdsPackage.targets b/tools/targets/GenerateMdsPackage.targets
index b4bf4a0d5c..2635354c1f 100644
--- a/tools/targets/GenerateMdsPackage.targets
+++ b/tools/targets/GenerateMdsPackage.targets
@@ -5,10 +5,11 @@
-
+
-
+ -command "&$(ToolsDir)scripts\downloadLatestNuget.ps1 -nugetDestPath '$(NuGetRoot)'""
+ Condition="!Exists('$(NuGetCmd)')" />
+
From 94427caa0e65c85a808438f9c09ab1b6988d1b8d Mon Sep 17 00:00:00 2001
From: Paul Medynski <31868385+paulmedynski@users.noreply.github.com>
Date: Mon, 15 Jun 2026 11:19:29 -0300
Subject: [PATCH 2/3] Fix MDS package step: install NuGet before
GenerateMdsPackage
The old generate-nuget-package-step.yml template used NuGetToolInstaller@1
and NuGetCommand@2 which provided nuget.exe implicitly. The replacement
DotNetCoreCLI@2 call invokes the GenerateMdsPackage MSBuild target which
shells out to nuget.exe, but nothing installs it on the agent.
Add NuGetToolInstaller@1 and pass -p:NuGetCmd=nuget.exe so the target
uses the PATH-installed binary instead of the BITS download fallback.
---
eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml | 6 ++++++
.../onebranch/jobs/build-signed-sqlclient-package-job.yml | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml b/eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml
index 130c361e50..43791bb0d7 100644
--- a/eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml
+++ b/eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml
@@ -146,6 +146,11 @@ jobs:
# Create the MDS NuGet package via build.proj's GenerateMdsPackage target.
# This target has access to the version range properties computed in
# Versions.props, so it passes them through to nuget pack automatically.
+ - task: NuGetToolInstaller@1
+ displayName: 'Install NuGet'
+ inputs:
+ checkLatest: true
+
- task: DotNetCoreCLI@2
displayName: 'Create MDS NuGet Package'
inputs:
@@ -160,6 +165,7 @@ jobs:
-p:AbstractionsPackageVersion=${{ parameters.abstractionsPackageVersion }}
-p:LoggingPackageVersion=${{ parameters.loggingPackageVersion }}
-p:PackagesDir=$(packagePath)
+ -p:NuGetCmd=nuget.exe
# When building in Package mode, the AKV Provider restore needs to find the MDS package
# we just built. Copy it to the local NuGet feed so NuGet.config can resolve it.
diff --git a/eng/pipelines/onebranch/jobs/build-signed-sqlclient-package-job.yml b/eng/pipelines/onebranch/jobs/build-signed-sqlclient-package-job.yml
index bd5cd9d271..d3a6245782 100644
--- a/eng/pipelines/onebranch/jobs/build-signed-sqlclient-package-job.yml
+++ b/eng/pipelines/onebranch/jobs/build-signed-sqlclient-package-job.yml
@@ -96,6 +96,11 @@ jobs:
# Create the MDS NuGet package via build.proj's GenerateMdsPackage target.
# This target has access to the version range properties computed in
# Versions.props, so it passes them through to nuget pack automatically.
+ - task: NuGetToolInstaller@1
+ displayName: 'Install NuGet'
+ inputs:
+ checkLatest: true
+
- task: DotNetCoreCLI@2
displayName: 'Create MDS NuGet Package'
inputs:
@@ -110,6 +115,7 @@ jobs:
-p:AbstractionsPackageVersion=$(abstractionsPackageVersion)
-p:LoggingPackageVersion=$(loggingPackageVersion)
-p:PackagesDir=$(PACK_OUTPUT)
+ -p:NuGetCmd=nuget.exe
- template: /eng/pipelines/onebranch/steps/esrp-code-signing-step.yml@self
parameters:
From 84b146a4f9b76adf35d9e39fc968ebd5f436e22b Mon Sep 17 00:00:00 2001
From: Paul Medynski <31868385+paulmedynski@users.noreply.github.com>
Date: Tue, 16 Jun 2026 11:03:51 -0300
Subject: [PATCH 3/3] Remove nuget.exe download script; add platform and
existence checks
- Delete tools/scripts/downloadLatestNuget.ps1 (only caller was
GenerateMdsPackage.targets; CI uses NuGetToolInstaller@1 instead)
- Replace download with Error if not running on Windows
(using MSBuild intrinsic IsOSPlatform)
- Use 'where' to verify nuget.exe is available on PATH or at the
configured path, with a clear error message and docs link
- Add NuGet CLI prerequisite section to BUILDGUIDE.md
---
BUILDGUIDE.md | 8 +++++++
tools/scripts/downloadLatestNuget.ps1 | 27 ------------------------
tools/targets/GenerateMdsPackage.targets | 18 +++++++++++++---
3 files changed, 23 insertions(+), 30 deletions(-)
delete mode 100644 tools/scripts/downloadLatestNuget.ps1
diff --git a/BUILDGUIDE.md b/BUILDGUIDE.md
index 8f13730f68..f0fd358a82 100644
--- a/BUILDGUIDE.md
+++ b/BUILDGUIDE.md
@@ -13,6 +13,14 @@ Tests and tools may require different .NET Runtimes that may be installed
independently. For example, tests targeting .NET 8.0 will need that runtime
installed.
+### NuGet CLI
+
+The `GenerateMdsPackage` build target uses `nuget.exe` to create the Microsoft.Data.SqlClient NuGet
+package, and is thus only supported on Windows build hosts. In CI, this is installed automatically
+by the `NuGetToolInstaller@1` pipeline task. For local builds, install the [NuGet
+CLI](https://learn.microsoft.com/nuget/install-nuget-client-tools) and ensure `nuget.exe` is on your
+PATH.
+
### Visual Studio
This project should be built with Visual Studio 2019+ for the best compatibility. The required set of components are provided in the below file:
diff --git a/tools/scripts/downloadLatestNuget.ps1 b/tools/scripts/downloadLatestNuget.ps1
deleted file mode 100644
index faddf3bb09..0000000000
--- a/tools/scripts/downloadLatestNuget.ps1
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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.
-# Script: downloadLatestNuget.ps1
-# Author: Keerat Singh
-# Date: 07-Dec-2018
-# Comments: This script downloads the latest NuGet Binary.
-#
-param(
- [string]$nugetDestPath,
- [string]$nugetSrcPath="https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
-)
-Function DownloadLatestNuget()
-{
- if(!$nugetDestPath)
- {
- $nugetDestPath = (Get-location).ToString() +'\.nuget\'
- }
- if (!(Test-Path $nugetDestPath))
- {
- New-Item -ItemType Directory -Path $nugetDestPath
- }
- Write-Output "Source: $nugetSrcPath"
- Write-Output "Destination: $nugetDestPath"
- Start-BitsTransfer -Source $nugetSrcPath -Destination $nugetDestPath\nuget.exe
-}
-DownloadLatestNuget
\ No newline at end of file
diff --git a/tools/targets/GenerateMdsPackage.targets b/tools/targets/GenerateMdsPackage.targets
index 2635354c1f..d77b175fec 100644
--- a/tools/targets/GenerateMdsPackage.targets
+++ b/tools/targets/GenerateMdsPackage.targets
@@ -7,9 +7,21 @@
-
+
+
+
+
+
+
+