Skip to content

Conversation

@priyankatiwari08
Copy link
Contributor

@priyankatiwari08 priyankatiwari08 commented Oct 13, 2025

Description

As part of adding support for .NET 10 below changes has been done:

  1. Added conditional logic for PackageReference entries for assemblies which are now included in the .NET 10 Base Class Library. Without this change, keeping them caused runtime redundancy and potential NU1510 errors during SDK pruning:

    • Sytem.Text.Json
    • System.Text.Encodings.Web
    • System.Buffers
    • System.Memory
    • System.Runtime.InteropServices.RuntimeInformation
  2. Enabled multi-targeting for .NET 10 in test projects to ensure compatibility and proper coverage.

Issues

#3576
Customer issue: #3522

@priyankatiwari08 priyankatiwari08 requested a review from a team as a code owner October 13, 2025 16:14
Copilot AI review requested due to automatic review settings October 13, 2025 16:14
@priyankatiwari08 priyankatiwari08 marked this pull request as draft October 13, 2025 16:14
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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 11 out of 11 changed files in this pull request and generated 2 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.

I think your best bet will be to update the pipelines to install the .NET 10 SDK (instead of .NET 9 SDK), and ensure that we use .NET 10 SDK to build and run the test projects.

The driver projects must remain using .NET 9 SDK to build.

Hmm... I don't think we can separate this out in our current pipelines. Let's just use the .NET 10 SDK for everything and see how it goes.

@paulmedynski paulmedynski self-assigned this Oct 15, 2025
@mdaigle
Copy link
Contributor

mdaigle commented Oct 15, 2025

The driver projects must remain using .NET 9 SDK to build.

@paulmedynski I've been thinking about this. We can start publishing a .NET 10 dll with only a minor version bump. Maybe we target our spring 7.1 release for that addition. At that point it should be better supported in all the build tooling.

@priyankatiwari08
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

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 14 out of 14 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Directory.Packages.props:49

  • The condition for Microsoft.Extensions.Hosting should be updated to include net10.0, similar to the other updated conditions in this file. Currently, net10.0 builds will fall into the 'not equal' condition on line 53, which may not be the intended behavior given the pattern established elsewhere in this file.
  <ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">

@priyankatiwari08 priyankatiwari08 marked this pull request as ready for review October 31, 2025 09:16
@apoorvdeshmukh
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines failed to run 2 pipeline(s).

@priyankatiwari08
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines failed to run 2 pipeline(s).

@priyankatiwari08
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines failed to run 2 pipeline(s).

@priyankatiwari08 priyankatiwari08 added this to the 7.0.0-preview3 milestone Oct 31, 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.

It would also be nice to expirment with the workaround documented here to see if we can eliminate the ensure-dotnet-version.yml template:

microsoft/azure-pipelines-tasks#16501 (comment)

And the alternate way to determine architecture here:

microsoft/azure-pipelines-tasks#20300 (comment)

That would de-clutter the job steps that look like we're repeatedly trying to install SDKs and remove our PowerShell foo.

@priyankatiwari08 priyankatiwari08 linked an issue Oct 31, 2025 that may be closed by this pull request
@Frulfump
Copy link

Any progress here now that .NET 10 is GA?

@ErikEJ
Copy link
Contributor

ErikEJ commented Nov 15, 2025

@Frulfump What are you missing in order to use SqlClient with .NET 10?

@Frulfump
Copy link

@ErikEJ not sure haven't tried it yet trying to be proactive here but given the name of this issue #3576 and the title of this PR "Adding support for .NET 10" it doesn't paint a picture of it being fully supported so hoping to get the wrinkles sorted out before I waste my time on something that might not be fully supported.
(Also the linked customer issue in this PR #3522)

@paulmedynski
Copy link
Contributor

MDS won't be targeting .NET 10 since we don't use any APIs specific to .NET 10. If that changes, we will add .NET 10 as a target framework.

This PR's goal is to ensure MDS can be built using the .NET 10 SDK. We will be updating the pipelines to use the .NET 10 SDK, and updating the tests to target .NET 10 to ensure things work in that runtime as well.

In the meantime, you can try using the .NET 10 SDK to build and test MDS. I have been using it without issues for a while.

@C0nquistadore
Copy link

MDS won't be targeting .NET 10 since we don't use any APIs specific to .NET 10. If that changes, we will add .NET 10 as a target framework.

I would be glad if you would reconsider targeting .NET 10 aswell, because right now without it, it can't be used on a project that targets .NET 10. A project that targets .NET 10 and references Microsoft.Data.SqlClient 6.1.3 throws the following exception during SqlConnection.Open:

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for 'Microsoft.Data.SqlClient.LocalAppContextSwitches' threw an exception.
  Source=System.Private.CoreLib
  StackTrace:
   at System.Runtime.CompilerServices.InitHelpers.InitClassSlow(MethodTable* mt)
   at System.Runtime.CompilerServices.StaticsHelpers.GetNonGCStaticBaseSlow(MethodTable* mt)
   at Microsoft.Data.SqlClient.LocalAppContextSwitches.get_UseConnectionPoolV2()
   at Microsoft.Data.SqlClient.ConnectionPool.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory connectionFactory)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject, DbConnectionPoolGroup connectionPoolGroup)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)
   at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
   at Microsoft.Data.SqlClient.SqlConnection.Open()
   at Program.<Main>$(String[] args)

  This exception was originally thrown at this call stack:

Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

The current workaround is to manually reference System.Configuration.ConfigurationManager 10.0.0.

Copilot AI review requested due to automatic review settings December 2, 2025 17:16
Copilot finished reviewing on behalf of priyankatiwari08 December 2, 2025 17:21
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 17 out of 17 changed files in this pull request and generated 2 comments.

… keyword.

- Ignoring NU1510 warnings when using the legacy MSBuild SDK (i.e. msbuild.exe), since it warns about package pruning that the .NET 10 SDK does not.
paulmedynski
paulmedynski previously approved these changes Dec 2, 2025
Copilot AI review requested due to automatic review settings December 2, 2025 18:23
Copilot finished reviewing on behalf of paulmedynski December 2, 2025 18:29
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 23 out of 23 changed files in this pull request and generated 2 comments.

@cheenamalhotra
Copy link
Member

cheenamalhotra commented Dec 2, 2025

@paulmedynski @priyankatiwari08
I think enabling .NET 10 targets in pipelines is going to blow up server instances used in tests and will increase failures due to resource limitations (e.g. xevent, enclaves, etc.) and our environments may not be ready for adding 100 more jobs to all pipeline runs. I'd recommend we wait for pipeline refactoring before extending pipelines to test with .NET 10.

@codecov
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.80%. Comparing base (995df25) to head (0575bf2).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...c/Microsoft/Data/SqlClient/Server/SqlNormalizer.cs 0.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (995df25) and HEAD (0575bf2). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (995df25) HEAD (0575bf2)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3686      +/-   ##
==========================================
- Coverage   76.61%   69.80%   -6.81%     
==========================================
  Files         274      268       -6     
  Lines       43393    66432   +23039     
==========================================
+ Hits        33247    46376   +13129     
- Misses      10146    20056    +9910     
Flag Coverage Δ
addons ?
netcore 69.87% <0.00%> (-6.81%) ⬇️
netfx 69.14% <0.00%> (-7.05%) ⬇️

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.

…ine test runs.

- Removed unnecessary System.Text.Json and Microsoft.Win32.Registry package dependencies that were causing pruning warnings.
- Updated MDS .nuspec dependencies to match what we actually depend on.
paulmedynski
paulmedynski previously approved these changes Dec 3, 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.

Commentary for reviewers.


- name: targetFrameworksLinux
displayName: 'Target Frameworks on Non-Windows'
default: [net462, net8.0, net9.0, net10.0]
Copy link
Contributor

Choose a reason for hiding this comment

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

These are just default values for this template. The top-level pipelines specify precisly which frameworks they want.


- name: targetFrameworksLinux
displayName: Target Frameworks on Non-Windows
default: [net462, net8.0, net9.0, net10.0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can afford to keep .NET 10 test runs active in the CI pipelines. They run serialized on commits to main, and once per day, so shoudln't blow our resource budget.

<PackageReference Include="System.Security.Cryptography.Pkcs" />

<!-- Transitive dependencies that would otherwise bring in older, vulnerable versions. -->
<PackageReference Include="System.Text.Json" />
Copy link
Contributor

Choose a reason for hiding this comment

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

MSBuild says we don't use this for .NET 8 or 9 and was producing pruning errors. I removed it and everything builds fine. We also don't have any Component Governance warnings, so it wasn't protecting us from transitive problems either.

<ErrorReport>None</ErrorReport>

<!-- This code analysis ruleset only exists with the .NET Framework toolset. -->
<CodeAnalysisRuleSet Condition="$(MSBuildRuntimeType) == 'Full'">MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
Copy link
Contributor

Choose a reason for hiding this comment

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

This was producing a warning when using MSBuild on Windows, so I think it's just old cruft that is no longer necessary.

<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
</ItemGroup>
<ItemGroup>
<PackageReference Condition="$(ReferenceType.Contains('Package'))" Include="Microsoft.Win32.Registry" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Not used, so removed.

<dependency id="Microsoft.IdentityModel.JsonWebTokens" version="8.14.0" />
<dependency id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="8.14.0" />
<dependency id="System.Buffers" version="4.6.1" />
<dependency id="System.Data.Common" version="4.3.0" />
Copy link
Contributor

Choose a reason for hiding this comment

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

I updated all of these dependencies to match what we actually reference in our projects.

Copilot AI review requested due to automatic review settings December 3, 2025 13:44
Copilot finished reviewing on behalf of paulmedynski December 3, 2025 13:50
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 26 out of 26 changed files in this pull request and generated 7 comments.

Comment on lines 58 to 59
<dependency id="System.Security.Cryptography.Pkcs" version="8.0.1" />
<dependency id="System.Text.Json" version="8.0.6" />
</group>
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

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

Removing System.Runtime.InteropServices.RuntimeInformation and System.Text.Json dependencies from the net8.0 target framework group is incorrect. These packages are NOT part of the .NET 8.0 Base Class Library - they are only included in .NET 10+.

According to the PR description and the conditional logic in src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj (lines 29-34), these packages should only be excluded for .NET 10+. For .NET 8.0, these must remain as explicit package dependencies.

The same issue exists for the net9.0 and netstandard2.0 groups. Either keep these dependencies for pre-.NET 10 frameworks, or add a dedicated net10.0 target framework group that excludes them.

Copilot uses AI. Check for mistakes.
<dependency id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" />
<dependency id="System.Security.Cryptography.Pkcs" version="9.0.9" />
<dependency id="System.Text.Json" version="9.0.9" />
</group>
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

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

Removing System.Runtime.InteropServices.RuntimeInformation and System.Text.Json dependencies from the net9.0 target framework group is incorrect. These packages are NOT part of the .NET 9.0 Base Class Library - they are only included in .NET 10+. These dependencies must remain for .NET 9.0.

Suggested change
</group>

Copilot uses AI. Check for mistakes.
<dependency id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" />
<dependency id="System.Security.Cryptography.Pkcs" version="8.0.1" />
<dependency id="System.Text.Json" version="8.0.6" />
<dependency id="System.Threading.Channels" version="8.0.0" />
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

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

Removing System.Runtime.InteropServices.RuntimeInformation and System.Text.Json dependencies from the netstandard2.0 target framework group is incorrect. These packages are NOT part of the .NET Standard 2.0 surface area - they must be explicit package dependencies for this target framework.

Suggested change
<dependency id="System.Threading.Channels" version="8.0.0" />
<dependency id="System.Threading.Channels" version="8.0.0" />
<dependency id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" />
<dependency id="System.Text.Json" version="8.0.6" />

Copilot uses AI. Check for mistakes.
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@priyankatiwari08
Copy link
Contributor Author

@dotnet-policy-service agree [company="Microsoft"]

@priyankatiwari08
Copy link
Contributor Author

@dotnet-policy-service agree company="Microsoft"

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prepare for .NET 10 SDK

9 participants