Repository navigation
Open
Labels
Area\Native SNIIssues that are targeted to the Native SNI codebase.
Description
Describe the bug
Microsoft.Data.SqlClient.SNI.targets adds PublishSNIFiles to PublishItemsOutputGroupDependsOn, but it doesn't add the published SNI files to PublishItemsOutputGroupOutputs.
I can't seem to find the source for this targets file on GitHub, so for reference, here's what it looks like on my local:
<!-- ~/.nuget/packages/microsoft.data.sqlclient.sni/5.2.0/buildTransitive/net462/Microsoft.Data.SqlClient.SNI.targets -->
<Target Name="PublishSNIFiles" AfterTargets="Publish"
Condition="'$(CopySNIFiles)' != 'false' And
'$(PublishSNIFiles)' != 'false' And
'$(PublishDir)' != '' And
'$(_DeploymentApplicationDir)' == '' And
HasTrailingSlash('$(PublishDir)') And
Exists('$(PublishDir)') And
'@(ClickOnce)' != ''"
Inputs="@(SNIDllFiles)"
Outputs="@(SNIDllFiles -> '$(PublishDir)%(RecursiveDir)%(Filename)%(Extension)')">
<!--
NOTE: Copy "Microsoft.Data.SqlClient.SNI.dll" only to the publish directory.
-->
<Copy SourceFiles="@(SNIDllFiles)"
DestinationFiles="@(SNIDllFiles -> '$(PublishDir)%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>It seems like this target should take the additional step of adding the SNI files to @(PublishItemsOutputGroupOutputs) so that downstream targets are aware that these items are part of the published output, e.g.:
<Target Name="PublishSNIFiles" AfterTargets="Publish"
Condition="'$(CopySNIFiles)' != 'false' And
'$(PublishSNIFiles)' != 'false' And
'$(PublishDir)' != '' And
'$(_DeploymentApplicationDir)' == '' And
HasTrailingSlash('$(PublishDir)') And
Exists('$(PublishDir)') And
'@(ClickOnce)' != ''"
Inputs="@(SNIDllFiles)"
Outputs="@(SNIDllFiles -> '$(PublishDir)%(RecursiveDir)%(Filename)%(Extension)')">
<!--
NOTE: Copy "Microsoft.Data.SqlClient.SNI.dll" only to the publish directory.
-->
<Copy SourceFiles="@(SNIDllFiles)"
DestinationFiles="@(SNIDllFiles -> '$(PublishDir)%(RecursiveDir)%(Filename)%(Extension)')" />
+ <ItemGroup>
+ <PublishItemsOutputGroupOutputs Include="@(SNIDllFiles)"
+ TargetPath="@(SNIDllFiles -> '%(Filename)%(Extension)')"
+ IsKeyOutput="true"
+ Condition="'@(SNIDllFiles)' != ''"
+ OutputPath="$(PublishDir)%(RecursiveDir)"
+ OutputGroup="PublishItemsOutputGroup" />
+ </ItemGroup>
</Target>To reproduce
<!-- SomeProject.csproj -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
</ItemGroup>
<Target Name="CreateDeployPackage" AfterTargets="AfterSdkPublish">
<!--
The logic here doesn't really matter, but including this to demonstrate what this
looks like in practice. The key take-away is that at the end, we want PublishDir
to look something like this:
PublishDir/
SomeProject.1.0.0.zip
but at present, we find something like this:
PublishDir/
SomeProject.1.0.0.zip
Microsoft.Data.SqlClient.SNI.arm64.dll
Microsoft.Data.SqlClient.SNI.x64.dll
Microsoft.Data.SqlClient.SNI.x86.dll
-->
<Move SourceFiles="@(PublishItemsOutputGroupOutputs->'%(OutputPath)')" DestinationFolder="$(PublishDir)/$(MSBuildProjectName).$(Version)" />
<ZipDirectory SourceDirectory="$(PublishDir)/$(MSBuildProjectName).$(Version)" DestinationFile="$(PublishDir)/$(MSBuildProjectName).$(Version).zip" />
<ItemGroup>
<_OrphanedFiles Include="$(PublishDir)/*" Exclude="$(PublishDir)/*.zip" />
</ItemGroup>
<Warning Text="@(_OrphanedFiles)" />
</Target>
</Project>$ dotnet publish
warning : bin\Debug\net48\publish\Microsoft.Data.SqlClient.SNI.arm64.dll;bin\Debug\net48\publish\Microsoft.Data.SqlClient.SNI.x64.dll;bin\Debug\net48\publish\Microsoft.Data.SqlClient.SNI.x86.dll
Build succeeded with 1 warning(s) in 1.3s
$ ls -1 bin/Debug/net48/publish/
Microsoft.Data.SqlClient.SNI.arm64.dll
Microsoft.Data.SqlClient.SNI.x64.dll
Microsoft.Data.SqlClient.SNI.x86.dll
SomeProject.1.0.0.zipExpected behavior
$ dotnet publish
Build succeeded in 1.3s
$ ls -1 bin/Debug/net48/publish/
SomeProject.1.0.0.zipMetadata
Metadata
Assignees
Labels
Area\Native SNIIssues that are targeted to the Native SNI codebase.
Type
Projects
- StatusShow more project fieldsBacklog
Activity
priyankatiwari08 commentedon Sep 17, 2026
/triage
github-actions commentedon Sep 17, 2026