Skip to content

Project that contains a <NativeRefrence> and references Microsoft.Data.SqlClient.SNI causes duplicate entries in manifest file #2173

Open

Description

@cgreger96

Describe the bug

This issue occurs when in the Microsoft.Data.SqlServer.SNI package when it is referenced by a project either directly or transitively and also contains a NativeReference.

Using a native reference causes a Native.{project}.mainifest to be generated for the project and all projects downstream.

Microsoft.Data.SqlClient.SNI package contains targets that add the Microsoft.Data.SqlClient.SNI.{arm64|x64|x86} to the manifest file. The target is AppendSNIDllsInManifest

This causes an issue with the project structured like in the linked repo since Microsoft.Data.SqlClient will add the dlls to both the generated Native manifest and the application manifest causing the following error event

<EventData>
  <Data>Microsoft.Data.SqlClient.SNI.arm64.dll</Data> 
  <Data>Two or more components referenced directly or indirectly by the application manifest have files by the same name.</Data> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data>{removed}\ConsoleApp1\bin\Debug\ConsoleApp1.exe.Manifest</Data> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
</EventData>

To reproduce

Example project: https://github.com/cgreger96/Manifest.Issue/

High level steps to reproduce

  1. Create .NET Framework class library
  2. Add reference to Microsoft.Data.SqlClient
  3. Add reference to Native manifest file
  4. Add a .NET Framework Console application
  5. Add a reference to the library
  6. Build
  7. Launch the console application

Expected behavior

Dlls are not added to native manifest files only to application manifest files

Further technical details

Microsoft.Data.SqlClient.SNI version: Seems to be in all versions after Microsoft.Data.SqlClient.SNI 2.0.0

.NET target: Framework 4.8.0

SQL Server version: NA

Operating system: Windows 10

Additional context

Workaround

The only work around I have found is to exclude buildTransitive from the SNI package from being used in projects the projects that generate Native manifests

	<PackageReference Include="Microsoft.Data.SqlClient.SNI">
		<ExcludeAssets>buildTransitive</ExcludeAssets>
	</PackageReference>

Generated manifest files

Interop.Accessibility.dll.manifest (Generated with mt.exe for this proof of concept)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity name="Interop.Accessibility.dll" version="1.1.0.0" processorArchitecture="msil"></assemblyIdentity>
    <clrSurrogate clsid="{3C157C7C-1B32-3EAE-8135-C4803D1F7BA1}" name="Accessibility.AnnoScope"></clrSurrogate>
    <clrSurrogate clsid="{C81D1FBC-1883-30E8-9C25-F0CFFCBC7B51}"
        name="Accessibility._RemotableHandle"></clrSurrogate>
    <clrSurrogate clsid="{9D071F73-DE7F-335C-ABF4-EDC6A2AA38CE}"
        name="Accessibility.__MIDL_IWinTypes_0009"></clrSurrogate>
    <clrSurrogate clsid="{B5F8350B-0548-48B1-A6EE-88BD00B4A5E7}"
        name="Accessibility.CAccPropServicesClass"></clrSurrogate>
    <file name="Interop.Accessibility.dll" hashalg="SHA1"></file>
</assembly>

Native.ClassLibrary1.manifest

<?xml version="1.0" encoding="utf-8"?>
<assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
  <assemblyIdentity name="Native.ClassLibrary1" version="1.0.0.0" type="win32" />
  <dependency>
    <dependentAssembly asmv2:dependencyType="install" asmv2:codebase="Interop.Accessibility.dll.manifest" asmv2:size="846">
      <assemblyIdentity name="Interop.Accessibility.dll" version="1.1.0.0" processorArchitecture="msil" />
      <hash xmlns="urn:schemas-microsoft-com:asm.v2">
        <dsig:Transforms>
          <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
        </dsig:Transforms>
        <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        <dsig:DigestValue>JpTY8l9nE8SUGUVnyxQpN+nJOWE=</dsig:DigestValue>
      </hash>
    </dependentAssembly>
  </dependency>
  <file name="Microsoft.Data.SqlClient.SNI.arm64.dll" size="491424" xmlns="urn:schemas-microsoft-com:asm.v2">
    <hash>
      <dsig:Transforms>
        <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
      </dsig:Transforms>
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
      <dsig:DigestValue>+YP7Bt6zRlIBadWdZYcNT+EczvM=</dsig:DigestValue>
    </hash>
  </file>
  <file name="Microsoft.Data.SqlClient.SNI.x64.dll" size="506272" xmlns="urn:schemas-microsoft-com:asm.v2">
    <hash>
      <dsig:Transforms>
        <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
      </dsig:Transforms>
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
      <dsig:DigestValue>Dz0UTswEQjMU9TqTbQ3puB6+6VI=</dsig:DigestValue>
    </hash>
  </file>
  <file name="Microsoft.Data.SqlClient.SNI.x86.dll" size="414096" xmlns="urn:schemas-microsoft-com:asm.v2">
    <hash>
      <dsig:Transforms>
        <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
      </dsig:Transforms>
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
      <dsig:DigestValue>gg3nO9o1UxdWz9st6dKpW9vxPhI=</dsig:DigestValue>
    </hash>
  </file>
</assembly>

ConsoleApp1.exe.manifest

<?xml version="1.0" encoding="utf-8"?>
<assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
  <assemblyIdentity name="ConsoleApp1.exe" version="1.0.0.0" type="win32" />
  <dependency>
    <dependentAssembly asmv2:dependencyType="install" asmv2:codebase="Interop.Accessibility.dll.manifest" asmv2:size="846">
      <assemblyIdentity name="Interop.Accessibility.dll" version="1.1.0.0" processorArchitecture="msil" />
      <hash xmlns="urn:schemas-microsoft-com:asm.v2">
        <dsig:Transforms>
          <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
        </dsig:Transforms>
        <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        <dsig:DigestValue>JpTY8l9nE8SUGUVnyxQpN+nJOWE=</dsig:DigestValue>
      </hash>
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly asmv2:dependencyType="install" asmv2:codebase="Native.ClassLibrary1.manifest" asmv2:size="2622">
      <assemblyIdentity name="Native.ClassLibrary1" version="1.0.0.0" type="win32" />
      <hash xmlns="urn:schemas-microsoft-com:asm.v2">
        <dsig:Transforms>
          <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
        </dsig:Transforms>
        <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        <dsig:DigestValue>Y4mE7xI8dSmwx819eGrYcJ0CsU4=</dsig:DigestValue>
      </hash>
    </dependentAssembly>
  </dependency>
  <file name="Microsoft.Data.SqlClient.SNI.arm64.dll" size="491424" xmlns="urn:schemas-microsoft-com:asm.v2">
    <hash>
      <dsig:Transforms>
        <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
      </dsig:Transforms>
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
      <dsig:DigestValue>+YP7Bt6zRlIBadWdZYcNT+EczvM=</dsig:DigestValue>
    </hash>
  </file>
  <file name="Microsoft.Data.SqlClient.SNI.x64.dll" size="506272" xmlns="urn:schemas-microsoft-com:asm.v2">
    <hash>
      <dsig:Transforms>
        <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
      </dsig:Transforms>
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
      <dsig:DigestValue>Dz0UTswEQjMU9TqTbQ3puB6+6VI=</dsig:DigestValue>
    </hash>
  </file>
  <file name="Microsoft.Data.SqlClient.SNI.x86.dll" size="414096" xmlns="urn:schemas-microsoft-com:asm.v2">
    <hash>
      <dsig:Transforms>
        <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
      </dsig:Transforms>
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
      <dsig:DigestValue>gg3nO9o1UxdWz9st6dKpW9vxPhI=</dsig:DigestValue>
    </hash>
  </file>
</assembly>

Activity

  1. JRahnama commented on Oct 3, 2023

    @JRahnama
    Contributor

    @cgreger96 We will look into this and will get back to you.

  2. jhennessey commented on Jul 12, 2024

    @jhennessey

    Still seeing this issue.

    For those looking for an alternative work-around, you can add this to a Directory.Build.props file to prevent the SNI files from being added to the manifest. If you are actually using ClickOnce you probably want to add the items as Content too (before AssignTargetPaths) to ensure they show in the application manifest.

      <Target Name="RemoveSqlClientNativeFilesFromManifest" BeforeTargets="GenerateApplicationManifest" Condition=" '@(_DeploymentManifestFiles)' != '' ">
        <ItemGroup>
          <ExcludedDeploymentManifestFiles Include="@(_DeploymentManifestFiles)" Condition=" $([System.String]::Copy('%(Filename)').Contains('Microsoft.Data.SqlClient.SNI')) " />
          <_DeploymentManifestFiles Remove="@(ExcludedDeploymentManifestFiles)" Condition=" '@(ExcludedDeploymentManifestFiles)' != '' " />
        </ItemGroup>
    
        <Message Text="Removed the following item from the '_DeploymentManifestFiles' itemgroup: %(ExcludedDeploymentManifestFiles.FullPath)" Importance="High" Condition=" '@(ExcludedDeploymentManifestFiles)' != '' " />
      </Target>

    Is there any reason why these files are directly added to the _DeploymentManifestFiles itemgroup? If they were added as Content items I think that may solve the issue and eliminate the need for the special copying logic in the .targets file?

  3. moved this from To triage to Backlog in SqlClient Boardon Jan 12, 2026
  4. added
    Area\Native SNI
    on Jan 12, 2026
  5. added
    Repro Available ✔️
    on Jan 12, 2026
  6. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  7. github-actions commented on Sep 17, 2026

    @github-actions

    🔍 Triage Summary (on-demand re-triage)

    Check Result
    Issue type Bug
    Environment All required environment details provided for investigation
    Area Area\Native SNI (already applied)
    Duplicates None found as exact duplicates; this is tracked as a sub-issue of the parent epic #4129 ("SNI loading issues")
    Regression Not a version regression in the traditional sense — reporter states the issue affects "all versions after Microsoft.Data.SqlClient.SNI 2.0.0", i.e. present since the AppendSNIDllsInManifest MSBuild target was introduced

    Analysis

    This is a build/packaging issue (not a runtime data-access bug): the Microsoft.Data.SqlClient.SNI package's AppendSNIDllsInManifest MSBuild target unconditionally appends the SNI platform DLLs (Microsoft.Data.SqlClient.SNI.{arm64|x64|x86}.dll) to _DeploymentManifestFiles. When a consuming project also generates a Native.*.manifest (via NativeReference items, e.g. ClickOnce-style native manifest generation), the same DLL ends up referenced in both the native manifest and the application manifest, causing a "Two or more components ... have files by the same name" error at manifest-generation/launch time. A community-provided workaround (excluding buildTransitive from the SNI package, or removing duplicate entries from _DeploymentManifestFiles in Directory.Build.props) confirms the root cause is in the SNI package's .targets file logic rather than in application code. Severity: P2 — narrow but real impact (only affects .NET Framework apps combining NativeReference + ClickOnce/manifest generation + Microsoft.Data.SqlClient.SNI), with a documented workaround, but it has been open since 2023 with continued reports.

    Next Steps

    • Assign this issue to Copilot coding agent to investigate the AppendSNIDllsInManifest target and related .targets/.props files in the Microsoft.Data.SqlClient.SNI native package (see src/Microsoft.Data.SqlClient.SNI* packaging assets) to determine whether SNI DLL entries can be added as Content items (as suggested by a commenter) instead of being force-appended to _DeploymentManifestFiles, or whether the target should detect and skip DLLs already present in a generated Native.*.manifest to avoid duplicate manifest entries.
    • Since this is tracked under the parent epic SNI loading issues #4129 ("SNI loading issues"), coordinate any fix with that broader effort to avoid conflicting changes.
    • Consider documenting the known workaround (excluding buildTransitive for the SNI package, or removing duplicates from _DeploymentManifestFiles in Directory.Build.props) in the repo's troubleshooting docs until a permanent fix ships.

    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 #2173 · copilot · auto · 61.6 AIC · ⌖ 14.6 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 SNIRepro Available ✔️

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions