dotnet / dotnet/SqlClient

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

Open
#2,173 2 comments 0 reactions 0 assignees View on GitHub
Area\Native SNI Repro Available :heavy_check_mark:
Dominant language
C#
Stars
989
Forks
340
Avg merge
4d 18h
Merged PRs (30d)
69

Description

### 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](https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items?view=vs-2022#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

``` xml

Microsoft.Data.SqlClient.SNI.arm64.dll
Two or more components referenced directly or indirectly by the application manifest have files by the same name.








{removed}\ConsoleApp1\bin\Debug\ConsoleApp1.exe.Manifest








```

### 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
```xml

buildTransitive

```
### Generated manifest files

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






```
Native.ClassLibrary1.manifest
```xml










JpTY8l9nE8SUGUVnyxQpN+nJOWE=









+YP7Bt6zRlIBadWdZYcNT+EczvM=








Dz0UTswEQjMU9TqTbQ3puB6+6VI=








gg3nO9o1UxdWz9st6dKpW9vxPhI=

```
ConsoleApp1.exe.manifest
```xml










JpTY8l9nE8SUGUVnyxQpN+nJOWE=











Y4mE7xI8dSmwx819eGrYcJ0CsU4=









+YP7Bt6zRlIBadWdZYcNT+EczvM=








Dz0UTswEQjMU9TqTbQ3puB6+6VI=








gg3nO9o1UxdWz9st6dKpW9vxPhI=

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.