Skip to content

PublishSNIFiles is part of PublishItemsOutputGroupDependsOn, but doesn't contribute to PublishItemsOutputGroupOutputs #3081

Open

Description

@austindrenski

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.zip

Expected behavior

$ dotnet publish

Build succeeded in 1.3s

$ ls -1 bin/Debug/net48/publish/
SomeProject.1.0.0.zip

Activity

  1. added
    Area\Native SNI
    and removed on Nov 20, 2025
  2. moved this from To triage to Backlog in SqlClient Boardon Nov 20, 2025
  3. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  4. github-actions commented on Sep 17, 2026

    @github-actions

    Generated by SqlClient Issue Auto-Triage for #3081 · copilot · auto · 56.4 AIC · ⌖ 12.9 AIC · ⊞ 11.9K · ◷

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area\Native SNI

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions