Open cgreger96 opened 1 year ago
@cgreger96 We will look into this and will get back to you.
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?
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
To reproduce
Example project: https://github.com/cgreger96/Manifest.Issue/
High level steps to reproduce
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
Generated manifest files
Interop.Accessibility.dll.manifest (Generated with mt.exe for this proof of concept)
Native.ClassLibrary1.manifest
ConsoleApp1.exe.manifest