Skip to content

Microsoft.Data.SqlClient.SNI files ends up in root folder #3525

Open

Description

@SaxoLigtorn

Describe the bug

It seems that when you

use the OutDir property, it doesn't copy the files to the correct location, but i ends up in the root folder instead

Target CopySNIFiles:
 Building target "CopySNIFiles" completely.
  Output file "..\binapp\Microsoft.Data.SqlClient.SNI.arm64.dll" does not exist.
  Output file "..\binapp\Microsoft.Data.SqlClient.SNI.arm64.pdb" does not exist.
  Output file "..\binapp\Microsoft.Data.SqlClient.SNI.x64.dll" does not exist.
  Output file "..\binapp\Microsoft.Data.SqlClient.SNI.x64.pdb" does not exist.
  Output file "..\binapp\Microsoft.Data.SqlClient.SNI.x86.dll" does not exist.
  Output file "..\binapp\Microsoft.Data.SqlClient.SNI.x86.pdb" does not exist.
  Task "Copy"
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.arm64.dll" to "C:\Projects\MSClientNuget\binapp\Microsoft.Data.SqlClient.SNI.arm64.dll".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.arm64.pdb" to "C:\Projects\MSClientNuget\binapp\Microsoft.Data.SqlClient.SNI.arm64.pdb".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x64.dll" to "C:\Projects\MSClientNuget\binapp\Microsoft.Data.SqlClient.SNI.x64.dll".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x86.dll" to "C:\Projects\MSClientNuget\binapp\Microsoft.Data.SqlClient.SNI.x86.dll".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x64.pdb" to "C:\Projects\MSClientNuget\binapp\Microsoft.Data.SqlClient.SNI.x64.pdb".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x86.pdb" to "C:\Projects\MSClientNuget\binapp\Microsoft.Data.SqlClient.SNI.x86.pdb".
  Done executing task "Copy".
Target _CopySNIWebApplicationLegacy:
 Task "Copy"
 Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.arm64.dll" to "C:\bin\Microsoft.Data.SqlClient.SNI.arm64.dll".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x64.dll" to "C:\bin\Microsoft.Data.SqlClient.SNI.x64.dll".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x86.dll" to "C:\bin\Microsoft.Data.SqlClient.SNI.x86.dll".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x86.pdb" to "C:\bin\Microsoft.Data.SqlClient.SNI.x86.pdb".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x64.pdb" to "C:\bin\Microsoft.Data.SqlClient.SNI.x64.pdb".
    Copying file from "C:\Users\xxx\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.arm64.pdb" to "C:\bin\Microsoft.Data.SqlClient.SNI.arm64.pdb".
  Done executing task "Copy".

To reproduce

I have attached a solution, which can be used for reproducing the issue
MSClientNuget.zip

Expected behavior

I expect it to end up in the outdir instead of the root folder

Activity

  1. cheenamalhotra commented on Jul 30, 2025

    @cheenamalhotra
    Member

    @SaxoLigtorn

    I cannot reproduce your issue, they all land in the correct folder:

    Image

    If you continue to face issues, please gather a binlog using '/bl' flag on msbuild command and share with us.

  2. SaxoLigtorn commented on Jul 30, 2025

    @SaxoLigtorn
    Author

    If you look at my detailed logs they show, that they are both in the root folder and outdir folder. Did you check your in your c:\ and would your account have permissions to write to that folder. I am running my VS as admin

  3. cheenamalhotra commented on Jul 31, 2025

    @cheenamalhotra
    Member

    Oh, I see now what you mean. I see a 'C:\bin' folder yes. Let me find out what's happening.

  4. SaxoLigtorn commented on Jul 31, 2025

    @SaxoLigtorn
    Author

    msbuild.zip in case you need it

  5. moved this from To triage to Backlog in SqlClient Boardon Oct 16, 2025
  6. tbolon commented on Jan 30, 2026

    @tbolon

    We are also impacted by this problem:

    _CopySNIWebApplicationLegacy:
      Copying file from "C:\Users\TFSService\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.arm64.dll" to "C:\bin\Microsoft.Data.SqlClient.SNI.arm64.dll".
      Copying file from "C:\Users\TFSService\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.arm64.pdb" to "C:\bin\Microsoft.Data.SqlClient.SNI.arm64.pdb".
      Copying file from "C:\Users\TFSService\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x64.pdb" to "C:\bin\Microsoft.Data.SqlClient.SNI.x64.pdb".
      Copying file from "C:\Users\TFSService\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x86.dll" to "C:\bin\Microsoft.Data.SqlClient.SNI.x86.dll".
      Copying file from "C:\Users\TFSService\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x64.dll" to "C:\bin\Microsoft.Data.SqlClient.SNI.x64.dll".
      Copying file from "C:\Users\TFSService\.nuget\packages\microsoft.data.sqlclient.sni\6.0.2\buildTransitive\net462\Microsoft.Data.SqlClient.SNI.x86.pdb" to "C:\bin\Microsoft.Data.SqlClient.SNI.x86.pdb".
    

    It also seems the dll are copied every time, even when the libraries are identical, our build logs are flooded by these messages for each library depending on Microsoft.Data.SqlClient (even transitive). The libraries are also copied to the standard output, even for libraries where the file are not necessary.

    Image
  7. tbolon commented on Jan 30, 2026

    @tbolon

    To add a hint, there is perhaps simply a condition missing in Microsoft.Data.SqlClient.SNI.targets in Microsoft.Data.SqlClient.SNI package.

    See this, line 83 of the latest SNI package:

      <Target Name="_CopySNIWebApplicationLegacy"
            AfterTargets="CopySNIFiles" 
            Condition="'$(Disable_CopyWebApplication)' != 'true' And '$(OutDir)' != '$(OutputPath)'">
    
        <Copy SourceFiles="@(SNIFiles)"
              DestinationFiles="@(SNIFiles -> '$(WebProjectOutputDir)\bin\%(RecursiveDir)%(Filename)%(Extension)')"/>
      </Target>

    Condition is missing a test to check if $(WebProjectOutputDir) is set, just like that: And '$(WebProjectOutputDir)' != ''.

    It will prevent this target from running for all libraries.

    Also the fact that the CopySNIFiles is run each time is a hint that the Inputs/Outputs attributes are not correctly set on the Target: 

    Edit: I can't reproduce this problem locally, so it's possible that something in our build pipeline causes this.

    <Target Name="CopySNIFiles"
              Condition="'$(CopySNIFiles)' != 'false' And
                         '$(OutDir)' != '' And
                         HasTrailingSlash('$(OutDir)') And
                         Exists('$(OutDir)')"
              Inputs="@(SNIFiles)"
              Outputs="@(SNIFiles -> '$(OutDir)%(RecursiveDir)%(Filename)%(Extension)')">
        <!--
            NOTE: Copy "Microsoft.Data.SqlClient.SNI.dll" and all related files, for every
                  architecture that we support, to the build output directory.        
        -->
        <Copy SourceFiles="@(SNIFiles)"
              DestinationFiles="@(SNIFiles -> '$(OutDir)%(RecursiveDir)%(Filename)%(Extension)')" />
      </Target>

    For me the "CopySNIFiles" should results in "Skipping target "CopySNIFiles" because all output files are up-to-date with respect to the input files." in most cases, since the files are identical.

    It seems the Incremental Build specification is not applied here, but I don't get why...

  8. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  9. github-actions commented on Sep 17, 2026

    @github-actions

    🔍 Triage Summary (on-demand re-triage)

    Check Result
    Issue type Bug
    Environment Mostly provided — Microsoft.Data.SqlClient.SNI version 6.0.2, .NET target net462 (via `buildTransitive
    et462), OS Windows (binlog/msbuild logs), and detailed repro attachments (MSClientNuget.zip, msbuild.zip`) are present; SQL Server version is not applicable since this is a build/packaging issue, not a runtime data-access issue
    Area Area\Native SNI
    Duplicates Potentially related: #936 (Microsoft.Data.SqlClient.SNI not deployed to _PublishedWebsites for an ASP.NET Web Application) — same Microsoft.Data.SqlClient.SNI.targets copy-target area
    Regression Not indicated — reporter did not mention a previously working version; behavior appears tied to Microsoft.Data.SqlClient.SNI.targets logic (specifically the CopySNIFiles / _CopySNIWebApplicationLegacy targets) rather than a version regression

    Analysis

    The Microsoft.Data.SqlClient.SNI NuGet package's MSBuild targets copy native SNI binaries both to the project's OutDir/WebProjectOutputDir and unconditionally to C:in (root), because the _CopySNIWebApplicationLegacy target in Microsoft.Data.SqlClient.SNI.targets appears to be missing a guard for '$(WebProjectOutputDir)' != ''. A follow-up commenter also reports the CopySNIFiles target re-running (and re-copying/re-logging) on every build even when outputs are already up to date, suggesting the target's Inputs/Outputs are not configured for MSBuild incremental build detection. This is a build/packaging (native SNI targets) issue, not a data-access defect. Severity: P2 — annoying/log-noise and unwanted files in unexpected build output locations, with a workaround (ignore/clean up extra files), but affects multiple users on Windows/.NET Framework builds using the native SNI package.

    Next Steps

    • Assign to Copilot coding agent to investigate Microsoft.Data.SqlClient.SNI.targets in the Microsoft.Data.SqlClient.SNI package (native SNI package sources), specifically the _CopySNIWebApplicationLegacy target's condition — add the missing '$(WebProjectOutputDir)' != '' guard so copying to the legacy web output path is skipped when not applicable.
    • Also investigate why CopySNIFiles re-executes and re-copies identical files on every build instead of being skipped via MSBuild incremental build (Inputs/Outputs attributes may need correction) as suggested by @tbolon's analysis.
    • Review the linked issue Microsoft.Data.SqlClient.SNI not deployed to _PublishedWebsites for an ASP.NET Web Application #936 before proceeding, as it covers related _PublishedWebsites/web application deployment behavior for the same SNI copy targets.
    • Validate the fix against the reporter's attached repro (MSClientNuget.zip) and the shared msbuild.zip binlog.

    Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.

    Generated by SqlClient Issue Auto-Triage for #3525 · copilot · auto · 58.3 AIC · ⌖ 13.1 AIC · ⊞ 11.9K · ◷

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

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions