Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@benrr101
Copy link
Contributor

Description

This PR kicks the tires on building the common project. The goal of this PR was simply to get the common project to build, generate artifacts, and cause no disturbances to existing projects or pipelines. Here's a rundown of the changes:

  • General tweaks to get the common project to build at all
    • Adding #if NET wrappers around SqlDependencyUtils.AppDomain.netcore.cs
    • Adding references to packages missing from the common project but present in the netfx/netcore projects
  • Change target frameworks based on OS being built
    • This may be marginally controversial - we've never had target frameworks be conditional before. However, not doing this causes issues when building on unix: files that are included only on windows builds will be exculded on unix, and the dependency chain goes much higher than just the conditionally included files. Thus, the easiest way to get around this for now is to just disable building netfx when building for unix. This can still be overridden by setting TargetOs to Windows_NT, enabling building netfx binaries on unix.
  • Introduce new artifacts paths
    • This shouldn't be controversial, but might seem messy for a bit.
    • You now have artifacts/Microsoft.Data.SqlClient/(configuration)/(targetos)/(targetframework)
      • I wanted to flatten the last two, but this isn't possible without mucking around with the obj folder path, and at that point it's too much complexity in the csproj.
    • Obj folder path is default (ie, in the same folder as the project) b/c we do not need to make it that complicated
  • Introducing a build2.proj file
    • This choice is more controversial. However, I'm doing it because I want to design as simple of a build procedure as possible, not beholden to existing variables, structures, etc. I also do not want to cause interference with the existing build.proj. And let's be real, build.proj is a mess - now is a good time for a fresh start.
    • It provides three targets
      • BuildMds - builds common project for unix and windows
      • BuildMdsUnix - builds common project for unix
      • BuildMdsWindows - builds common project for windows
    • It also use dotnet to do the build instead.

Testing

  • Project builds in IDE on windows and linux
  • Project builds from direct command line on windows and linux
  • Project builds from build2.proj command line on windows and linux

@benrr101 benrr101 added this to the 7.0.0-preview4 milestone Dec 10, 2025
Copilot AI review requested due to automatic review settings December 10, 2025 00:03
@benrr101 benrr101 requested a review from a team as a code owner December 10, 2025 00:03
@benrr101 benrr101 added the Common Project 🚮 Things that relate to the common project project label Dec 10, 2025
Copy link
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

This PR establishes the foundation for building a unified "common" Microsoft.Data.SqlClient project that consolidates code from the platform-specific netfx and netcore projects. The changes enable conditional target framework selection based on the target OS (net462 only on Windows), introduce OS-aware artifact output paths, and provide new build targets via build2.proj. Key modifications include adding #if NET preprocessor directives to platform-specific files, refactoring UDT exception creation code, updating package references, and adjusting file references in the netcore project to point to renamed SqlDependency files with .netcore.cs extensions.

  • Conditional target frameworks: net462 only included when building for Windows
  • New artifact directory structure: artifacts/(AssemblyName)/(Configuration)/(TargetOs)/(TargetFramework)
  • build2.proj provides BuildMds, BuildMdsUnix, and BuildMdsWindows targets for streamlined builds

Reviewed changes

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

Show a summary per file
File Description
SqlDependencyUtils.AssemblyLoadContext.netcore.cs New file with #if NET wrapper for AssemblyLoadContext-based unloading support
SqlDependencyUtils.AppDomain.netcore.cs Added #if NET wrapper to conditionally compile AppDomain unload logic
AdapterUtil.cs Refactored UDT exception creation, improved formatting, moved TraceExceptionAsReturnValue call outside conditional blocks
Microsoft.Data.SqlClient.csproj Added conditional target frameworks, new artifact paths, package reference reorganization for netfx vs netcore
netcore/src/Microsoft.Data.SqlClient.csproj Updated file references from .cs to .netcore.cs for SqlDependencyUtils files
Microsoft.Data.SqlClient.sln Added Build.0 configurations for common project to enable building in Visual Studio
build2.proj New build orchestration file with targets for building common project on Unix and Windows

Copy link
Contributor

@edwardneal edwardneal left a comment

Choose a reason for hiding this comment

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

No major comments, just a confirmation of Copilot and a quick naming nit.

The commentary about OS-specific handling comes at the same time as I've been looking at what kind of work would be needed to eliminate the need for it entirely. It looks like almost everything can be trivially lifted into runtime checks, with one or two benchmarks to be run for cases where Unix has a slightly different class structure. I'm hoping to start unwinding the need for this soon.

@priyankatiwari08 priyankatiwari08 self-assigned this Dec 10, 2025
@paulmedynski paulmedynski self-assigned this Dec 11, 2025
Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Looking for some commentary on a few things, and some suggestions.

Copy link
Contributor

@mdaigle mdaigle left a comment

Choose a reason for hiding this comment

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

Mainly curious if it compiles for framework, because we seem to be missing a lot of references.

…et/sqlclient into dev/russellben/build-common-project

... working on two different machines
Copilot AI review requested due to automatic review settings December 16, 2025 19:22
Copy link
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 6 out of 7 changed files in this pull request and generated 6 comments.

mdaigle
mdaigle previously approved these changes Dec 16, 2025
Copy link
Contributor

@mdaigle mdaigle left a comment

Choose a reason for hiding this comment

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

Looks good overall. Want to take a close look at the dependencies, but doesn't need to happen in this PR.

Copilot AI review requested due to automatic review settings December 17, 2025 19:45
@benrr101
Copy link
Contributor Author

@mdaigle Net462 is building happily - Can't guarantee it all works yet, but that's the goal of the next PR :)

image

Copy link
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 6 out of 7 changed files in this pull request and generated 3 comments.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Looks pretty good! Just a couple of pedantic comments :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Common Project 🚮 Things that relate to the common project project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants