I've got a project with a NuGet package reference to snt.ScintillaNet.FindReplaceDialog
.
This package in turn has a reference to the unsigned package ScintillaNET
.
My application has to be signed so I referenced the signed version of the ScintillaNET
package.
This works well and the application is working fine.
However when building I get the following warning:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3243: No way to resolve conflict between "ScintillaNET, Version=3.6.3.0, Culture=neutral, PublicKeyToken=d42c48f11a620156" and "ScintillaNET, Version=3.6.3.0, Culture=neutral, PublicKeyToken=null". Choosing "ScintillaNET, Version=3.6.3.0, Culture=neutral, PublicKeyToken=d42c48f11a620156" arbitrarily.
This makes sense, the build system sees 2 references, one signed and one unsigned.
It then picks up the one I want (signed) and everything works fine.
I want to remove that warning from the build.
I tried to put MSB3243
as a warning exception in the project, but as it's a MSBuild warning and not a compiler warning it cannot be ignored.
I came up with a very ugly hack that I'm going to put down as an answer to help anyone else that comes across the same issue (and myself when I forget my solution).
To get around the issue I ask the build system to ignore the unsigned version.
To do that I explicitly added the unsigned version of the NuGet package to the project together with the signed version.
Then I manually changed the reference in the .csproj file to the following:
<!-- Hack to prevent the unsigned library to load and raise an assembly conflict -->
<PackageReference Include="jacobslusser.ScintillaNET">
<Version>3.6.3</Version>
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
This prevents all artifacts from being copied during the NuGet package resolution.
It's ugly but works so I'd like to get a cleaner way of achieving the same effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With