From 871859c12551583faf69596bc8051e91b88f853b Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Thu, 4 Dec 2025 17:24:43 -0600 Subject: [PATCH 01/12] Add reference to MSS for netcore to fix InvalidUdtException reference issue --- .../src/Microsoft.Data.SqlClient.csproj | 21 ++++++++++------ .../src/Microsoft/Data/Common/AdapterUtil.cs | 25 +++++++++++-------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index 69ddbf01fd..6e22e0fd51 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -27,8 +27,8 @@ + - @@ -38,18 +38,25 @@ + + - - - - - - + + + + + + + + diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs index dcd9f4bac9..a7d62148df 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs @@ -69,24 +69,27 @@ internal static partial class ADP internal const int MaxBufferAccessTokenExpiry = 600; #region UDT -#if NETFRAMEWORK - private static readonly MethodInfo s_method = typeof(InvalidUdtException).GetMethod("Create", BindingFlags.NonPublic | BindingFlags.Static); -#endif + + #if NETFRAMEWORK + private static readonly MethodInfo s_udtConstructor = + typeof(InvalidUdtException).GetMethod("Create", BindingFlags.NonPublic | BindingFlags.Static); + #endif + /// /// Calls "InvalidUdtException.Create" method when an invalid UDT occurs. /// internal static InvalidUdtException CreateInvalidUdtException(Type udtType, string resourceReasonName) { - // @TODO: Can we adopt the netcore version? - InvalidUdtException e = -#if NETFRAMEWORK - (InvalidUdtException)s_method.Invoke(null, new object[] { udtType, resourceReasonName }); - ADP.TraceExceptionAsReturnValue(e); -#else - InvalidUdtException.Create(udtType, resourceReasonName); -#endif + #if NETFRAMEWORK + InvalidUdtException e = (InvalidUdtException)s_udtConstructor.Invoke(null, [udtType, resourceReasonName]); + #else + InvalidUdtException e = InvalidUdtException.Create(udtType, resourceReasonName); + #endif + + TraceExceptionAsReturnValue(e); return e; } + #endregion static private void TraceException(string trace, Exception e) From 8250468c2ed54228f20a5119a33232787cb5f0e2 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Thu, 4 Dec 2025 17:36:42 -0600 Subject: [PATCH 02/12] SqlDependencyUtils.* are all netcore files, rename as such, and wrap in #if NET --- .../netcore/src/Microsoft.Data.SqlClient.csproj | 8 ++++---- ...pDomain.cs => SqlDependencyUtils.AppDomain.netcore.cs} | 4 ++++ ... => SqlDependencyUtils.AssemblyLoadContext.netcore.cs} | 0 3 files changed, 8 insertions(+), 4 deletions(-) rename src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/{SqlDependencyUtils.AppDomain.cs => SqlDependencyUtils.AppDomain.netcore.cs} (97%) rename src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/{SqlDependencyUtils.AssemblyLoadContext.cs => SqlDependencyUtils.AssemblyLoadContext.netcore.cs} (100%) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj index 73c0cb3c9c..8235f71fb7 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -815,11 +815,11 @@ Microsoft\Data\SqlClient\SqlDependencyUtils.cs - - Microsoft\Data\SqlClient\SqlDependencyUtils.AppDomain.cs + + Microsoft\Data\SqlClient\SqlDependencyUtils.AppDomain.netcore.cs - - Microsoft\Data\SqlClient\SqlDependencyUtils.AssemblyLoadContext.cs + + Microsoft\Data\SqlClient\SqlDependencyUtils.AssemblyLoadContext.netcore.cs Microsoft\Data\SqlClient\SqlEnclaveAttestationParameters.Crypto.cs diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.netcore.cs similarity index 97% rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.netcore.cs index d82a9fc8fa..9e030d7c42 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.netcore.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NET + using System; namespace Microsoft.Data.SqlClient @@ -18,3 +20,5 @@ partial void SubscribeToAppDomainUnload() } } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AssemblyLoadContext.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AssemblyLoadContext.netcore.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AssemblyLoadContext.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AssemblyLoadContext.netcore.cs From d2537673797c4e508e74dc2163806c215f1c34ec Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Fri, 5 Dec 2025 15:54:05 -0600 Subject: [PATCH 03/12] Set build output path --- .../src/Microsoft.Data.SqlClient.csproj | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index 6e22e0fd51..a3a3c0aa2f 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -1,8 +1,9 @@  net462;net8.0;net9.0 + Debug;Release; + true - @@ -20,6 +21,11 @@ $(DefineConstants),_WINDOWS + + + $(Artifacts)bin/$(Configuration)/$(AssemblyName)/$(TargetFramework)-$(TargetOs.ToLower()) + + - + @@ -50,6 +56,7 @@ + + + + From 477219dfd019827c6836f46b88d5f2efbbee0a80 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Fri, 5 Dec 2025 17:21:16 -0600 Subject: [PATCH 04/12] Add OS-specific check for target frameworks Remove runtime identifier/target framework from output path --- .../src/Microsoft.Data.SqlClient.csproj | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index a3a3c0aa2f..8ea08e28fa 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -1,6 +1,6 @@  - - net462;net8.0;net9.0 + + Debug;Release; true @@ -17,12 +17,21 @@ - $(DefineConstants),_UNIX - $(DefineConstants),_WINDOWS + $(DefineConstants);_UNIX + $(DefineConstants);_WINDOWS + + + + + + net8.0;net9.0 + $(TargetFrameworks);net462 + false + false $(Artifacts)bin/$(Configuration)/$(AssemblyName)/$(TargetFramework)-$(TargetOs.ToLower()) From 70fa18faa9b9894fdbbbfc633b2e7b5e5fb9ebd4 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Fri, 5 Dec 2025 17:50:07 -0600 Subject: [PATCH 05/12] Builds! Whoohooo! --- .../src/Microsoft.Data.SqlClient.csproj | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index 8ea08e28fa..9f94fbfede 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -8,6 +8,7 @@ + $(OS) @@ -16,7 +17,7 @@ - + $(DefineConstants);_UNIX $(DefineConstants);_WINDOWS @@ -30,15 +31,23 @@ - false - false - $(Artifacts)bin/$(Configuration)/$(AssemblyName)/$(TargetFramework)-$(TargetOs.ToLower()) + + $(RepoRoot)artifacts/ + + + + + $(ArtifactPath)$(AssemblyName)/$(Configuration)/$(TargetOs.ToLower())/ + + + + + Condition="'$(TargetOs.ToUpper())' == 'WINDOWS_NT' AND '$(TargetFramework)' == 'net462'" /> From 61978e1e72641c6cba6d0242f20e4ac534ce8db9 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Fri, 5 Dec 2025 17:56:35 -0600 Subject: [PATCH 06/12] Common project build targets --- build2.proj | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 build2.proj diff --git a/build2.proj b/build2.proj new file mode 100644 index 0000000000..a3a1aec2a5 --- /dev/null +++ b/build2.proj @@ -0,0 +1,53 @@ + + + + + + + + Debug + + + + + + + + + + + + + + $(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj + + + + + + + + + + $(DotnetPath)dotnet build $(MdsProjectPath) + -p:Configuration=$(Configuration) + -p:TargetOs=Unix + + $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) + + + + + + + + + $(DotnetPath)dotnet build $(MdsProjectPath) + -p:Configuration=$(Configuration) + -p:TargetOs=Unix + + $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) + + + + \ No newline at end of file From 946f41b09407c47953dec520aaae68c26327e0a6 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Tue, 9 Dec 2025 17:45:42 -0600 Subject: [PATCH 07/12] Add common project back to the solution build targets --- src/Microsoft.Data.SqlClient.sln | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient.sln b/src/Microsoft.Data.SqlClient.sln index 6696a8a31d..8b4f420f19 100644 --- a/src/Microsoft.Data.SqlClient.sln +++ b/src/Microsoft.Data.SqlClient.sln @@ -1,4 +1,4 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 @@ -561,6 +561,12 @@ Global {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|Any CPU.ActiveCfg = Release|Any CPU {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|x64.ActiveCfg = Release|Any CPU {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|x86.ActiveCfg = Release|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Debug|x64.Build.0 = Debug|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Debug|x86.Build.0 = Debug|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|Any CPU.Build.0 = Release|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|x64.Build.0 = Release|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|x86.Build.0 = Release|Any CPU {4461063D-2F2B-274C-7E6F-F235119D258E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4461063D-2F2B-274C-7E6F-F235119D258E}.Debug|Any CPU.Build.0 = Debug|Any CPU {4461063D-2F2B-274C-7E6F-F235119D258E}.Debug|x64.ActiveCfg = Debug|x64 From 2e920201086a626a261d1c4e67aec07aaebf22cc Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Wed, 10 Dec 2025 11:42:14 -0600 Subject: [PATCH 08/12] Comments from PR --- build2.proj | 2 +- .../src/Microsoft.Data.SqlClient.csproj | 2 +- .../src/Microsoft/Data/Common/AdapterUtil.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build2.proj b/build2.proj index a3a1aec2a5..49ba90514d 100644 --- a/build2.proj +++ b/build2.proj @@ -44,7 +44,7 @@ $(DotnetPath)dotnet build $(MdsProjectPath) -p:Configuration=$(Configuration) - -p:TargetOs=Unix + -p:TargetOs=Windows $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index 9f94fbfede..338944ccff 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -47,7 +47,7 @@ + Condition="'$(TargetOs.ToUpper())' == 'WINDOWS_NT' AND '$(TargetFramework)' != 'net462'" /> diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs index a7d62148df..64f827e261 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs @@ -71,7 +71,7 @@ internal static partial class ADP #region UDT #if NETFRAMEWORK - private static readonly MethodInfo s_udtConstructor = + private static readonly MethodInfo s_udtFactory = typeof(InvalidUdtException).GetMethod("Create", BindingFlags.NonPublic | BindingFlags.Static); #endif @@ -81,7 +81,7 @@ internal static partial class ADP internal static InvalidUdtException CreateInvalidUdtException(Type udtType, string resourceReasonName) { #if NETFRAMEWORK - InvalidUdtException e = (InvalidUdtException)s_udtConstructor.Invoke(null, [udtType, resourceReasonName]); + InvalidUdtException e = (InvalidUdtException)s_udtFactory.Invoke(null, [udtType, resourceReasonName]); #else InvalidUdtException e = InvalidUdtException.Create(udtType, resourceReasonName); #endif From 8d4ca14b29a96e35fa3b48837da2a7facda4703a Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Tue, 16 Dec 2025 13:16:38 -0600 Subject: [PATCH 09/12] Rework package references as per comments, add normalized target os variable. --- build2.proj | 2 +- .../src/Microsoft.Data.SqlClient.csproj | 55 ++++++++++--------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/build2.proj b/build2.proj index a3a1aec2a5..fc1ba2b6e9 100644 --- a/build2.proj +++ b/build2.proj @@ -44,7 +44,7 @@ $(DotnetPath)dotnet build $(MdsProjectPath) -p:Configuration=$(Configuration) - -p:TargetOs=Unix + -p:TargetOs=Windows_NT $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index 9f94fbfede..22a930d2b9 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -16,17 +16,19 @@ + $(TargetOs.ToLower()) + - $(DefineConstants);_UNIX - $(DefineConstants);_WINDOWS + $(DefineConstants);_UNIX + $(DefineConstants);_WINDOWS net8.0;net9.0 - $(TargetFrameworks);net462 + $(TargetFrameworks);net462 @@ -37,7 +39,7 @@ - $(ArtifactPath)$(AssemblyName)/$(Configuration)/$(TargetOs.ToLower())/ + $(ArtifactPath)$(AssemblyName)/$(Configuration)/$(NormalizedTargetOs)/ @@ -47,42 +49,45 @@ + Condition="'$(NormalizedTargetOs)' == 'windows_nt' AND '$(TargetFramework)' == 'net462'" /> - - + + + + + + + All + runtime; build; native; contentfiles; analyzers; buildtransitive + - - - - - - - - - + + + + + - + + + + + + + + - - - - - + From 2a0ff493bcaa0fd78d2d96b3d4032c327a9981a7 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Tue, 16 Dec 2025 15:19:39 -0600 Subject: [PATCH 10/12] Add message on exec --- build2.proj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build2.proj b/build2.proj index d9f9c62970..3a0bf16c1a 100644 --- a/build2.proj +++ b/build2.proj @@ -33,9 +33,11 @@ -p:Configuration=$(Configuration) -p:TargetOs=Unix + $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) - + + @@ -46,8 +48,10 @@ -p:Configuration=$(Configuration) -p:TargetOs=Windows_NT + $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) - + + From ca43c2017b1392b775b77490fc0f4d776314f611 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Wed, 17 Dec 2025 13:45:45 -0600 Subject: [PATCH 11/12] Add strong name signing and triple check package references --- .../src/Microsoft.Data.SqlClient.csproj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index 0880a8cd49..c686d19f00 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -6,6 +6,16 @@ true + + + true + $(SigningKeyPath) + $(SigningKeyPath) + + + $(SigningKeyPath) + + @@ -58,6 +68,7 @@ + @@ -69,6 +80,8 @@ + + From 392702b6417cc8223d40985afb09e1cdf0c14e2a Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Wed, 17 Dec 2025 18:48:47 -0600 Subject: [PATCH 12/12] Unconditional assembly originator key file, clarify command --- build2.proj | 8 ++++---- .../src/Microsoft.Data.SqlClient.csproj | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build2.proj b/build2.proj index 3a0bf16c1a..479d802f12 100644 --- a/build2.proj +++ b/build2.proj @@ -33,8 +33,8 @@ -p:Configuration=$(Configuration) -p:TargetOs=Unix - - $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) + + $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s+", " ")) @@ -48,8 +48,8 @@ -p:Configuration=$(Configuration) -p:TargetOs=Windows_NT - - $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) + + $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s+", " ")) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index c686d19f00..9bfceb3dc0 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -7,14 +7,14 @@ + + $(SigningKeyPath) + true $(SigningKeyPath) - $(SigningKeyPath) - - - $(SigningKeyPath) +