Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
</ItemGroup>

<!-- Published - Target Framework Specific Dependencies -->
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == '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.

You could use $([MSBuild]::VersionGreaterThanOrEquals(...)) here and below.

Copy link
Author

Choose a reason for hiding this comment

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

I made this change and tried building the driver code but it resulted in below error:

error MSB4184: The express
ion "[MSBuild]::VersionGreaterThanOrEquals('', net9.0)" cannot be evaluated. Version string was not in a correct format.

On checking further could understand that since we have multi-targetting with TargetFrameworks, MSBuild sets $(TargetFramework) for each target during the build, but during initial evaluation or restore, it may be unset leading to $TargetFramework being empty which caused above error.

Hence, I believe its rather safe to use below:

• It directly checks for the exact target frameworks you want (net9.0 or net10.0).
• It avoids MSBuild errors if $(TargetFramework) is empty or not a valid version string.
• It is more readable and less error-prone than using VersionGreaterThanOrEquals, which can fail if the property is not set.

Copy link
Contributor

@paulmedynski paulmedynski Oct 31, 2025

Choose a reason for hiding this comment

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

Have a look at the docs for VersionGreaterThanOrEquals here:

https://learn.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2022#msbuild-version-comparison-functions

You could also try using IsTargetFrameworkCompatible:

https://learn.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2022#msbuild-targetframework-and-targetplatform-functions

$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net9.0'))

That should be false when $(TargetFramework) is net8.0, and true for net9.0 and net10.0.

I think that is actually better than using VersionGreaterThanOrEquals.

<!-- MDS and AKV -->
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.9" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net9.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net9.0' and '$(TargetFramework)' != 'net10.0'">
<!-- MDS and AKV -->
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
</ItemGroup>
Expand Down Expand Up @@ -72,13 +72,13 @@
</ItemGroup>

<!-- Common Target Framework Specific Dependencies -->
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net10.0'">
<PackageVersion Include="Microsoft.Bcl.Cryptography" Version="9.0.9" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="9.0.9" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="9.0.9" />
<PackageVersion Include="System.Text.Json" Version="9.0.9" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net9.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net9.0' and '$(TargetFramework)' != 'net10.0'">
<PackageVersion Include="Microsoft.Bcl.Cryptography" Version="8.0.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="8.0.1" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="8.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="System.Text.Encodings.Web" />
<!--<PackageReference Include="System.Text.Encodings.Web" />-->
<PackageReference Include="Azure.Security.KeyVault.Keys" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
</ItemGroup>
</Project>
<ItemGroup Condition="$([MSBuild]::VersionLessThan('$(NETCoreSdkVersion)', '10.0.100'))">
<PackageReference Include="System.Text.Encodings.Web" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@
<PackageReference Include="Microsoft.SqlServer.Server" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="System.Security.Cryptography.Pkcs" />

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

<ItemGroup Condition="$([MSBuild]::VersionLessThan('$(NETCoreSdkVersion)', '10.0.100'))">
<PackageReference Include="System.Text.Json" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,10 @@
<PackageReference Include="System.Security.Cryptography.Pkcs" />

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

<ItemGroup Condition="$([MSBuild]::VersionLessThan('$(NETCoreSdkVersion)', '10.0.100'))">
<PackageReference Include="System.Text.Json" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" />
<PackageReference Include="System.Buffers" />
<!--<PackageReference Include="System.Buffers" />-->
Copy link
Contributor

Choose a reason for hiding this comment

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

Tidy up these commented-out lines.

<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="System.Memory" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
<!--<PackageReference Include="System.Memory" />-->
<!--<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />-->
<PackageReference Include="System.Security.Cryptography.Pkcs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
Expand All @@ -27,4 +27,10 @@
<PackageReference Include="System.Data.Common" />
<PackageReference Include="System.ValueTuple" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::VersionLessThan('$(NETCoreSdkVersion)', '10.0.100'))">
<PackageReference Include="System.Buffers" />
<PackageReference Include="System.Memory" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Microsoft.Data.SqlClient/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<!--These properties can be modified locally to target .NET version of choice to build and test entire test suite-->
<PropertyGroup>
<TargetNetFxVersion Condition="'$(TargetNetFxVersion)' == ''">net462</TargetNetFxVersion>
<TargetNetCoreVersion Condition="'$(TargetNetCoreVersion)' == ''">net8.0;net9.0</TargetNetCoreVersion>
<TargetNetCoreVersion Condition="'$(TargetNetCoreVersion)' == ''">net8.0;net9.0;net10.0</TargetNetCoreVersion>
</PropertyGroup>

<Choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@
</ItemGroup>
<!-- XUnit and XUnit extensions -->
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient.SNI.runtime" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyName>PerformanceTests</AssemblyName>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
Copy link
Contributor

Choose a reason for hiding this comment

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

So, making this change will require that we start using the .NET 10 SDK to build the tests everywhere (locally as devs and during all pipelines).

For devs, that's fine - we just need to install the .NET 10 SDK wherever we're developing. We will need to update the BUILDGUIDE.md to reflect this new requiremet.

For pipelines, we will need to find everywhere that we perform a build of the tests and add a step that installs the .NET 10 SDK. If you do this, then you can use the existing CI pipelines to verify .NET 10 compatibility rather than trying to get the tests to run for you locally (which is close to impossible currently).

<Configurations>Debug;Release;</Configurations>
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform).$(AssemblyName)</IntermediateOutputPath>
<OutputPath>$(BinFolder)$(Configuration).$(Platform).$(AssemblyName)</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!-- Properties common to all projects in this solution. -->
<PropertyGroup>
<!-- Target all frameworks that MDS supports. -->
<TargetFrameworks>net462;net47;net471;net472;net48;net481;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net462;net47;net471;net472;net48;net481;net8.0;net9.0;net10.0</TargetFrameworks>

<!--
Use the latest C# language version, regardless of what a particular
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<StartupObject>Microsoft.Data.SqlClient.ExtUtilities.Runner</StartupObject>
<TargetFrameworks>net9.0</TargetFrameworks>
<TargetFrameworks>net9.0;net10.0</TargetFrameworks>
Copy link
Contributor

@paulmedynski paulmedynski Oct 31, 2025

Choose a reason for hiding this comment

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

You can remove net9.0 here. This project builds a tool that we use during the build, so it only needs to target one runtime.

</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" />
Expand All @@ -11,7 +11,6 @@
Transitive dependencies with vulnerabilities, so we explicitly ask for
non-vulnerable versions.
-->
<PackageReference Include="System.Formats.Asn1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj" />
Expand Down
Loading