Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b0afd95
Stubbing out additional targets for build2.proj
benrr101 Feb 9, 2026
a7a9bf7
Fix issue with target OS and target frameworks in common MDS build
benrr101 Feb 10, 2026
4065b08
Adding targets to build2.proj for testing MDS, removing AKV provider …
benrr101 Feb 28, 2026
83cc907
Adding build target for MDS ref project
benrr101 Feb 28, 2026
154b150
Get common ref project building to artifacts folder, a la common mds …
benrr101 Feb 26, 2026
04ebcb7
Add stub for notsupported project
benrr101 Feb 28, 2026
86e75e3
Add GenAPI projects to the solution file under notsupported folder
benrr101 Mar 2, 2026
392723b
Move GenAPI output path to bin folder for project - they are not "art…
benrr101 Mar 2, 2026
1b406ce
Not supported assemblies are building via new project
benrr101 Mar 3, 2026
a214c38
Do not build not supported assembly and genapi projects as part of so…
benrr101 Mar 3, 2026
406d810
Ignore the notsupported GenAPI files
benrr101 Mar 3, 2026
82d73ae
Comments from copilot
benrr101 Mar 4, 2026
5c3e3c2
Remove Directory.Build.props and move target frameworks listing to th…
benrr101 Mar 4, 2026
7187e3e
Conditionally enable net462 on Azure test project
benrr101 Mar 4, 2026
a904283
Removing Directory.Build.props from test/tools
benrr101 Mar 4, 2026
3c45064
Add trim docs for intellisense to ref project (just inline it)
benrr101 Mar 5, 2026
f47ae65
Rework the package version arguments in build2.proj - this will make …
benrr101 Mar 5, 2026
1689a0a
Merge branch 'main' into dev/russellben/common/notsupported
benrr101 Mar 5, 2026
a50381e
Fix GenAPI for legacy build
benrr101 Mar 5, 2026
8706133
No clue whatsoever why this fixes functional tests on net462, but hey…
benrr101 Mar 6, 2026
2e332c6
Actionable PR comments
benrr101 Mar 5, 2026
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,6 @@ MigrationBackup/

# Config Json file
**/config.json

# MDS "Not Supported" GenAPI code
**/notsupported/*.cs
319 changes: 299 additions & 20 deletions build2.proj

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/Microsoft.Data.SqlClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Data.SqlClient",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient\src\Microsoft.Data.SqlClient.csproj", "{AA77C107-9A78-4A99-98BB-21FF7A1E0B01}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "notsupported", "notsupported", "{351BE847-A0BF-450C-A5BC-8337AFA49EAA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient\notsupported\Microsoft.Data.SqlClient.csproj", "{1DB299CE-95EA-4566-84DD-171768758291}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DotNet.GenAPI", "..\tools\GenAPI\Microsoft.DotNet.GenAPI\Microsoft.DotNet.GenAPI.csproj", "{583E2B51-A90B-4F34-AD8B-4061504E855E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Cci.Extensions", "..\tools\GenAPI\Microsoft.Cci.Extensions\Microsoft.Cci.Extensions.csproj", "{2F900B8A-EA19-4274-9AE9-3E6A59856FCC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -791,6 +799,24 @@ Global
{AA77C107-9A78-4A99-98BB-21FF7A1E0B01}.Release|x64.Build.0 = Release|Any CPU
{AA77C107-9A78-4A99-98BB-21FF7A1E0B01}.Release|x86.ActiveCfg = Release|Any CPU
{AA77C107-9A78-4A99-98BB-21FF7A1E0B01}.Release|x86.Build.0 = Release|Any CPU
{1DB299CE-95EA-4566-84DD-171768758291}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DB299CE-95EA-4566-84DD-171768758291}.Debug|x64.ActiveCfg = Debug|Any CPU
{1DB299CE-95EA-4566-84DD-171768758291}.Debug|x86.ActiveCfg = Debug|Any CPU
{1DB299CE-95EA-4566-84DD-171768758291}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DB299CE-95EA-4566-84DD-171768758291}.Release|x64.ActiveCfg = Release|Any CPU
{1DB299CE-95EA-4566-84DD-171768758291}.Release|x86.ActiveCfg = Release|Any CPU
{583E2B51-A90B-4F34-AD8B-4061504E855E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{583E2B51-A90B-4F34-AD8B-4061504E855E}.Debug|x64.ActiveCfg = Debug|Any CPU
{583E2B51-A90B-4F34-AD8B-4061504E855E}.Debug|x86.ActiveCfg = Debug|Any CPU
{583E2B51-A90B-4F34-AD8B-4061504E855E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{583E2B51-A90B-4F34-AD8B-4061504E855E}.Release|x64.ActiveCfg = Release|Any CPU
{583E2B51-A90B-4F34-AD8B-4061504E855E}.Release|x86.ActiveCfg = Release|Any CPU
{2F900B8A-EA19-4274-9AE9-3E6A59856FCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F900B8A-EA19-4274-9AE9-3E6A59856FCC}.Debug|x64.ActiveCfg = Debug|Any CPU
{2F900B8A-EA19-4274-9AE9-3E6A59856FCC}.Debug|x86.ActiveCfg = Debug|Any CPU
{2F900B8A-EA19-4274-9AE9-3E6A59856FCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F900B8A-EA19-4274-9AE9-3E6A59856FCC}.Release|x64.ActiveCfg = Release|Any CPU
{2F900B8A-EA19-4274-9AE9-3E6A59856FCC}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -866,6 +892,10 @@ Global
{020A7E7B-04C9-4326-985F-045B42CC2200} = {7289C27E-D7DF-2C71-84B4-151F3A162493}
{D433ED2D-5E47-4A4B-B94A-EC71482715C7} = {020A7E7B-04C9-4326-985F-045B42CC2200}
{AA77C107-9A78-4A99-98BB-21FF7A1E0B01} = {2B71F605-037E-5629-6E23-0FA3C297446D}
{351BE847-A0BF-450C-A5BC-8337AFA49EAA} = {7289C27E-D7DF-2C71-84B4-151F3A162493}
{1DB299CE-95EA-4566-84DD-171768758291} = {351BE847-A0BF-450C-A5BC-8337AFA49EAA}
{583E2B51-A90B-4F34-AD8B-4061504E855E} = {351BE847-A0BF-450C-A5BC-8337AFA49EAA}
{2F900B8A-EA19-4274-9AE9-3E6A59856FCC} = {351BE847-A0BF-450C-A5BC-8337AFA49EAA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {01D48116-37A2-4D33-B9EC-94793C702431}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Everybody hold onto your pants because this is going to get a bit ugly.

The purpose of this project is to generate a "Not Supported" version of the MDS assembly. At a
high level, this is done by:
* Building the ref project (as a dependency to this project)
* Feeding the ref assembly to GenAPI (built separately)
* GenAPI generates a single cs file with the entire API surface implemented to throw
Comment thread
paulmedynski marked this conversation as resolved.
PlatformNotSupportedExceptions
* This cs file is included as a compilation item in this project.

The big question might be: Why do we need a "Not Supported" version of MDS?
In some situations, most importantly PowerShell, including a NuGet package will automatically
reference the appropriate assembly in the /lib folder of the package, which is inherently OS-
agnostic. MDS implementation assemblies are placed in the /runtimes folder to provide the OS-
specific versions of MDS. The "Not Supported" binary is thus placed in the lib folder so that
in OS-agnostic situations, the user is reminded to reference an OS-specific version of MDS.

The next big question might be: Why is this a separate project?
In previous iterations, generating the "Not Supported" binaries was part of the netcore ref
project and netcore src project. This made it necessary to conditionally switch the project
and all associated variables from "implementation" mode into "not supported" mode. It was
very difficult to understand what was going on. Creating a separate project just for
"not supported" mode simplifies this considerably. It also makes it much cleaner to excise
when this project is no longer required.

The last big question might be: Why does this need to be a project at all?
Since it looks like we're just running a static GenAPI program against the ref binaries, surely
we could just do that as an arbitrary command execution in the build.proj file, right? Well,
not really. GenAPI needs a list of folders to find built-in reference libraries. To get that
list correctly, we need access to @(ReferencePath), which is most easily done by passing it in
as an input to a target in a csproj. What's more, we need to compile the source that GenAPI
generates. Unless we want to manually call csc (and who wants to do that) we need a project.

NOTE: If you are trying to build this from your IDE - YOU ARE DOING IT WRONG.
This project depends on the ref binaries and the GenAPI project in a way that is not conducive
to building in a project. Build the not supported binaries in one command via build2.proj
Comment thread
paulmedynski marked this conversation as resolved.
Outdated

> msbuild build2.proj /t:BuildMdsNotSupported

@TODO: Remove this project
The primary prerequisite for removing this project is making the "common" MDS project OS-
agnostic. Once that happens, the lib binary will be able to switch OS implementation at runtime
and a "not supported" error is no longer necessary.

alternatively:
@TODO: Replace the GenAPI project with a C# Source Generator
-->

<!-- General Properties ============================================== -->
<PropertyGroup>
<AssemblyName>Microsoft.Data.SqlClient</AssemblyName>
<TargetFrameworks>net462;net8.0;net9.0;netstandard2.0</TargetFrameworks>
Comment thread
paulmedynski marked this conversation as resolved.

<!--
Files to compile will be generated per-framework by the GenerateNotSupportedSource target and
included via Compile tags. Leaving this enabled will cause warnings about files being
included more than once.
-->
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>

<!-- Disable obsolete member usage warning -->
<NoWarn>$(NoWarn);CS0618</NoWarn>
</PropertyGroup>

<!-- BUild Output ==================================================== -->
Comment thread
benrr101 marked this conversation as resolved.
Outdated
<PropertyGroup>
<!--
MSBuild will add the target framework to the end of this path by default. Telling it not to
is possible but also requires specifying the IntermediateOutputPath. So while it would be
nice to have a flatter directory structure, it's more hassle than its worth.
-->
<OutputPath>$(RepoRoot)artifacts/$(AssemblyName).notsupported/$(Configuration)/</OutputPath>
</PropertyGroup>

<!-- References ====================================================== -->
<!--
Reference the ref project to cause it to be built, so we can use it as the contract to build
not supported assemblies against. Note, this must be set to output item type of none otherwise
the assemblies for the ref project will be compied to the output for this project, causing
Comment thread
benrr101 marked this conversation as resolved.
Outdated
conflicts that fail the build.
-->
<PropertyGroup>
<RefProjectPath>$(RepoRoot)src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.csproj</RefProjectPath>
<RefArtifactPath>$(RepoRoot)artifacts/Microsoft.Data.SqlClient.ref/$(Configuration)/$(TargetFramework)/Microsoft.Data.SqlClient.dll</RefArtifactPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(RefProjectPath)"
ReferenceOutputAssembly="false"
Private="false"
OutputItemType="None" />
</ItemGroup>

<!--
Reference to Abstractions package. Even though the ref project has a reference to the
abstractions package, the binaries will not be copied into this project's output, so we need to
make our own reference to the package to ensure it is brought in for compilation.
-->
<ItemGroup>
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/Abstractions.csproj"
Condition="'$(ReferenceType)' != 'Package'" />
<PackageReference Include="Microsoft.Data.SqlClient.Extensions.Abstractions"
Condition="'$(ReferenceType)' == 'Package'" />
</ItemGroup>

<!-- References to external packages that the API refers to -->
<!-- References for netframework -->
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml" />

<PackageReference Include="Microsoft.Bcl.Cryptography" />
<PackageReference Include="Microsoft.Data.SqlClient.SNI"
PrivateAssets="all"
IncludeAssets="runtime;build;native;contentfiles;analyzers;buildtransitive" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" />
<PackageReference Include="System.Buffers" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
<PackageReference Include="System.Security.Cryptography.Pkcs" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="System.Threading.Channels" />
</ItemGroup>

<!-- References for netstandard -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.Cryptography" />
<PackageReference Include="Microsoft.Data.SqlClient.SNI.runtime" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" />
<PackageReference Include="Microsoft.SqlServer.Server" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="System.Security.Cryptography.Pkcs" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="System.Threading.Channels" />
</ItemGroup>

<!-- References for netcore -->
<ItemGroup Condition="'$(TargetFramework)' != 'net462' AND '$(TargetFramework)' != 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.Cryptography" />
<PackageReference Include="Microsoft.Data.SqlClient.SNI.runtime" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" />
<PackageReference Include="Microsoft.SqlServer.Server" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="System.Security.Cryptography.Pkcs" />
</ItemGroup>

<!-- Generate "Not Supported" Source ================================= -->
<PropertyGroup>
<NotSupportedSourceFile>$(AssemblyName).$(TargetFramework).notsupported.cs</NotSupportedSourceFile>
</PropertyGroup>

<Target Name="GenerateNotSupportedSource"
BeforeTargets="CoreCompile"
DependsOnTargets="ResolveReferences">

<!-- Verify that GenAPI and ref projects were built successfully -->
<Error Text="Ref project output was not found at: '$(RefArtifactPath)'"
Condition="!Exists('$(RefArtifactPath)')" />
<Error Text="GenAPI project output was not found at: '$(GenApiPath)'"
Condition="!Exists('$(GenApiPath)')" />

<!--
Cleanup the list of reference path directories by trimming trailing \ and removing
duplicates.
-->
<ItemGroup>
<_referencePathDirectoriesWithDuplicates
Include="@(ReferencePath->'%(RootDir)%(Directory)'->TrimEnd('\'))" />
<_referencePathDirectories
Include="%(_referencePathDirectoriesWithDuplicates.Identity)" />
</ItemGroup>

<!-- Execute GenAPI against the ref assembly to generate the source file -->
<PropertyGroup>
<GenApiCommand>
$(DotnetPath)dotnet "$(GenApiPath)"
$(RefArtifactPath)
-l:"@(_referencePathDirectories)"
-o:"$(NotSupportedSourceFile)"
-t:"Microsoft.Data.SqlClient is not supported on this platform."
</GenApiCommand>
<!-- Convert more than one whitespace character into one space -->
<GenApiCommand>$([System.Text.RegularExpressions.Regex]::Replace($(GenApiCommand), "\s+", " "))</GenApiCommand>
</PropertyGroup>

<Message Text=">>> Building MDS ref binaries via command: $(DotnetCommand)"/>
Comment thread
benrr101 marked this conversation as resolved.
Outdated
<Exec Command="$(GenApiCommand)" ConsoleToMsBuild="true" />

<!-- Include the "Not Supported" source file into this project -->
<ItemGroup>
<Compile Include="$(NotSupportedSourceFile)" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@
</AssemblyAttribute>
</ItemGroup>

<!-- Strong name signing ============================================= -->
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
</PropertyGroup>

Comment thread
paulmedynski marked this conversation as resolved.
<!-- Build Output ==================================================== -->
<PropertyGroup>
<!-- @TODO: Move to directory.build.props? -->
<ArtifactPath>$(RepoRoot)artifacts/</ArtifactPath>

<!--
MSBuild will add the target framework to the end of this path by default. Telling it not to
is possible but also requires specifying the IntermediateOutputPath. So while it would be
nice to have a flatter directory structure, it's more hassle than its worth.
-->
<OutputPath>$(ArtifactPath)$(AssemblyName).ref/$(Configuration)/</OutputPath>
</PropertyGroup>

<!-- References ====================================================== -->
<!-- Reference to Abstractions -->
<ItemGroup>
Expand Down
43 changes: 23 additions & 20 deletions src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,30 @@
</AssemblyAttribute>
</ItemGroup>

<!-- When we're not signing, we are permitted to expose our internals to tests. -->
<!-- Strong name signing ============================================= -->
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
</PropertyGroup>
<!-- Otherwise, we're not signing, so we are permitted to expose our internals to tests. -->
<ItemGroup Condition="'$(SigningKeyPath)' == ''">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>UnitTests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

Comment thread
benrr101 marked this conversation as resolved.
<!-- Target Frameworks =============================================== -->
<PropertyGroup>
<TargetFrameworks>net462;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<!-- OS Constants ==================================================== -->
<PropertyGroup>
<!-- @TODO: Move to directory.build.props? -->
<!--
If a target OS was not specified, we must choose a reasonable default.

For .NET Framework targets, we can assume a target OS of Windows, since
we don't support .NET Framework on any other OS.

For .NET targets, we will use the host OS, since that is where the
resulting artifacts are likely to be executed (i.e. tests).

Official builds should always explicitly specify a target OS.
-->
<TargetOs Condition="'$(TargetOs)' == '' AND '$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))' == '.NETFramework'">Windows_NT</TargetOs>
<!-- If the TargetOs was not specified (as is the case during IDE development), the build -->
<!-- should target the host OS. -->
<TargetOs Condition="'$(TargetOs)' == ''">$(OS)</TargetOs>

<!-- Uncomment the following line to override the OS you are developing for -->
<!-- The following lines are provided for developer convenience. Many IDEs will automatically -->
<!-- hide code that is excluded via pre-compiler directives, making it difficult to edit in -->
<!-- the IDE when on the wrong OS. To ease this, uncomment one of the following lines to -->
<!-- force one OS or another. This is only for development usage. Do not commit these lines -->
<!-- uncommented. -->
<!--<TargetOs>Unix</TargetOs>-->
<!--<TargetOs>Windows_NT</TargetOs>-->

Expand All @@ -55,6 +49,15 @@
<DefineConstants Condition="'$(NormalizedTargetOs)' == 'windows_nt'">$(DefineConstants);_WINDOWS</DefineConstants>
</PropertyGroup>

<!-- Target Frameworks =============================================== -->
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>

<!-- We cannot build netfx unless we are building for Windows. Thus, we will only add netfx if -->
<!-- we are building for Windows. -->
<TargetFrameworks Condition="'$(NormalizedTargetOs)' == 'windows_nt'">$(TargetFrameworks);net462</TargetFrameworks>
</PropertyGroup>

<!-- Build Output ==================================================== -->
<PropertyGroup>
<!-- @TODO: Move to directory.build.props? -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<LangVersion>8.0</LangVersion>
<IsPackable>true</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputPath>$(ToolsArtifactsDir)</OutputPath>
</PropertyGroup>

<PropertyGroup>
Expand Down
Loading
Loading