Skip to content

Migrate SqlClient packaging to dotnet pack and centralize pack fallback#4257

Merged
paulmedynski merged 15 commits into
mainfrom
dev/paul/dotnet-pack-sqlclient
May 8, 2026
Merged

Migrate SqlClient packaging to dotnet pack and centralize pack fallback#4257
paulmedynski merged 15 commits into
mainfrom
dev/paul/dotnet-pack-sqlclient

Conversation

@paulmedynski
Copy link
Copy Markdown
Contributor

@paulmedynski paulmedynski commented May 4, 2026

Summary

  • switch PackSqlClient from nuget.exe pack to dotnet pack
  • move SqlClient pack configuration into src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj
  • generate an intermediate nuspec so dependency version tokens and $Version$ are materialized before SDK pack runs
  • move Abstractions/Logging sibling version fallback into the SqlClient project so direct project pack can evaluate defaults without requiring build.proj to precompute them
  • simplify build.proj PackSqlClient so it forwards pack inputs and lets the SqlClient project own SqlClient-specific pack behavior
  • update the remaining nuget pack pipeline template to pass Version via -properties
  • refresh BUILDGUIDE.md, TESTGUIDE.md, and src/Microsoft.Data.SqlClient/src/sqlclient-dotnet-pack.md, and address the Copilot review follow-ups for property naming, repro docs, and nuspec token details

Validation

  • built SqlClient artifacts with dotnet msbuild build.proj -t:BuildSqlClient
  • packed this branch with dotnet msbuild build.proj -t:PackSqlClient -p:PackBuild=false
  • packed main using nuget.exe pack against the same built artifacts for comparison
  • compared both .nupkg files after extraction
  • verified all 52 DLLs are byte-for-byte identical between the two packages
  • confirmed the only package differences are packaging-tool metadata (repository commit, lastModifiedBy, and derived relationship/core-properties identifiers)
  • smoke-tested the follow-up fallback path with dotnet msbuild src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj -t:PrepareSqlClientPackNuspec -p:ReferenceType=Project -p:BuildNumber=1234 -p:BuildSuffix=dev -p:SqlClientPackageVersion=7.1.0-preview1-dev1234

Notes

  • no public API changes
  • no test files were changed; this PR is scoped to packaging, pipeline, and documentation behavior
  • package content and dependency metadata remain functionally equivalent to main

Copilot AI review requested due to automatic review settings May 4, 2026 14:22
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board May 4, 2026
@paulmedynski paulmedynski added the Area\Engineering Use this for issues that are targeted for changes in the 'eng' folder or build systems. label May 4, 2026
@paulmedynski paulmedynski moved this from To triage to In progress in SqlClient Board May 4, 2026
@paulmedynski paulmedynski added this to the 7.1.0-preview2 milestone May 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates Microsoft.Data.SqlClient packaging from nuget.exe pack to an SDK-driven dotnet pack flow, moving pack configuration into the main project and introducing an intermediate nuspec generation step to avoid SDK/NuGet token-substitution issues for dependency versions.

Changes:

  • Switch PackSqlClient from nuget.exe pack to dotnet pack in build.proj.
  • Add dotnet pack/nuspec configuration to Microsoft.Data.SqlClient.csproj, including PrepareSqlClientPackNuspec to materialize dependency versions + package version into an intermediate nuspec.
  • Add documentation describing the pack flow and the upstream SDK substitution behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/Microsoft.Data.SqlClient/src/sqlclient-dotnet-pack.md New doc describing the SDK-based pack flow, repro, and rationale for generating an intermediate nuspec.
src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Adds pack defaults and a pre-GenerateNuspec target to generate a token-expanded nuspec for dotnet pack.
build.proj Updates PackSqlClient target to run dotnet pack and removes NugetPath/nuget.exe usage.
Comments suppressed due to low confidence (1)

build.proj:545

  • GetSqlClientPackageVersionCommand uses dotnet build ... -getProperty:SqlClientPackageVersion. -getProperty is an MSBuild switch and may be rejected by dotnet build argument parsing (unless forwarded via --), which would break PackSqlClient. Consider switching back to dotnet msbuild for this query, or explicitly forwarding MSBuild-only args (dotnet build ... -- -getProperty:...).
      <GetSqlClientPackageVersionCommand>
        "$(DotnetPath)dotnet" build "$(SqlClientProjectPath)"
        -nologo
        -verbosity:quiet
        -getProperty:SqlClientPackageVersion

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread src/Microsoft.Data.SqlClient/src/sqlclient-dotnet-pack.md Outdated
Comment thread build.proj Outdated
Copilot AI review requested due to automatic review settings May 4, 2026 17:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread src/Microsoft.Data.SqlClient/src/sqlclient-dotnet-pack.md Outdated
Comment thread src/Microsoft.Data.SqlClient/src/sqlclient-dotnet-pack.md Outdated
Comment thread BUILDGUIDE.md Outdated
Comment thread src/Microsoft.Data.SqlClient/src/sqlclient-dotnet-pack.md Outdated
@paulmedynski
Copy link
Copy Markdown
Contributor Author

Addressing Copilot review comments from commit 2851620:

Comment on line 116 (template brittleness): Replaced hardcoded XML string replacement with dedicated $NuspecVersion$ token, matching the pattern for $COMMITID$ and other tokens. This is resilient to template formatting changes.

Comment on line 47 (repro command docs): Added clarifying text explaining the repro command demonstrates the SDK bug. Added a second example with the required -p:PackageVersionAbstractions and -p:PackageVersionLogging MSBuild properties that triggers PrepareSqlClientPackNuspec.

Comment on line 51 (spelling): Fixed 'occured' → 'occurred'.

Comment in BUILDGUIDE.md (grammar): Fixed 'bulding' → 'building' and 'also handle by' → 'also handled by'.

Comment on line 80 (NuspecVersion): Clarified that NuspecVersion is derived from $(Version) by SDK defaults and removed it from the dynamic values list.

Comment thread BUILDGUIDE.md
Comment thread BUILDGUIDE.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.39%. Comparing base (b1c082e) to head (b52b37a).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4257      +/-   ##
==========================================
- Coverage   65.95%   64.39%   -1.56%     
==========================================
  Files         276      270       -6     
  Lines       42981    65777   +22796     
==========================================
+ Hits        28346    42357   +14011     
- Misses      14635    23420    +8785     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 64.39% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paulmedynski paulmedynski moved this from In progress to In review in SqlClient Board May 4, 2026
@paulmedynski paulmedynski marked this pull request as ready for review May 4, 2026 22:37
@paulmedynski paulmedynski requested a review from a team as a code owner May 4, 2026 22:37
Copilot AI review requested due to automatic review settings May 4, 2026 22:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread src/Microsoft.Data.SqlClient/src/sqlclient-dotnet-pack.md Outdated
Comment thread src/Microsoft.Data.SqlClient/src/sqlclient-dotnet-pack.md Outdated
Comment thread tools/specs/Microsoft.Data.SqlClient.nuspec Outdated
Replace nuget.exe invocation in build.proj with dotnet pack.
Add PrepareSqlClientPackNuspec target in the SqlClient csproj to
materialize dependency version tokens into an intermediate nuspec
before pack runs, working around SDK token-substitution limitations
in dependency version fields (dotnet/sdk#15482).

Pack design notes and known SDK behavior documented in
src/Microsoft.Data.SqlClient/src/sqlclient-dotnet-pack.md.
…, and NuspecVersion clarity

- Replace hardcoded version XML with $NuspecVersion$ token in nuspec template (fixes brittle string replacement)
- Update csproj to replace the dedicated token instead of hardcoded XML string (resilient to formatting changes)
- Add clarifying text to repro command explaining PrepareSqlClientPackNuspec requirements
- Fix spelling: 'occured' → 'occurred' in error message
- Fix grammar/spelling in BUILDGUIDE.md: 'bulding' → 'building', 'also handle by' → 'also handled by'
- Clarify NuspecVersion derives from $(Version) by SDK defaults and doesn't need explicit passing
- Align PrepareSqlClientPackNuspec error guidance with direct dotnet pack properties and build.proj aliases

- Update sqlclient-dotnet-pack.md replacement list to use $NuspecVersion$ token

- Correct direct repro command to pass AbstractionsPackageVersion/LoggingPackageVersion and clarify entrypoint property translation
apoorvdeshmukh
apoorvdeshmukh previously approved these changes May 5, 2026
Copy link
Copy Markdown
Contributor

@apoorvdeshmukh apoorvdeshmukh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. Branch has some expected conflicts that need to be resolved and copilot has some doc comments that can be considered.

- Move Abstractions/Logging version fallback into SqlClient pack target

- Reuse shared sibling project paths and DOTNET_HOST_PATH

- Document intermediate nuspec generation and sibling version evaluation

- Pass NuspecVersion through shared nuget pack pipeline properties
Comment thread eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread tools/specs/Microsoft.Data.SqlClient.nuspec Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread build.proj
Comment thread build.proj Outdated
Comment thread build.proj Outdated
Comment thread BUILDGUIDE.md Outdated
@github-project-automation github-project-automation Bot moved this from In review to In progress in SqlClient Board May 7, 2026
Copilot AI review requested due to automatic review settings May 8, 2026 13:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.nuspec
@paulmedynski paulmedynski moved this from In progress to In review in SqlClient Board May 8, 2026
@paulmedynski paulmedynski moved this from In review to To triage in SqlClient Board May 8, 2026
@paulmedynski paulmedynski moved this from To triage to In review in SqlClient Board May 8, 2026
@paulmedynski paulmedynski enabled auto-merge (squash) May 8, 2026 15:26
Copy link
Copy Markdown
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's good 🤷‍♂️
I'm a bit sketched out by all the magic that's going on with known-but-unknown build targets, known-but-unknown properties, etc. I almost think its better to just keep using nuget.exe since it's clearer what's going on rather than shoehorning the behavior into dotnet pack. But it is nice to not have to have a separate nuget.exe file to do everything.

The "right" way to do this is to eliminate os-specific builds, eliminate the ref and unsupported projects, and then eliminate the nuspec file. But ... that's a lot longer of a process, and idk if we'll ever get funding for it. Anyways, just know I'm uneasy about this change but I'll go ahead with it.

@paulmedynski paulmedynski merged commit 822dca4 into main May 8, 2026
301 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in SqlClient Board May 8, 2026
@paulmedynski paulmedynski deleted the dev/paul/dotnet-pack-sqlclient branch May 8, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area\Engineering Use this for issues that are targeted for changes in the 'eng' folder or build systems.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants