How to resolve Multiple assemblies being imported on a newly imported Nuget package for Xamarin Forms

1 answer

Disclaimer, I am creating the Nuget in question.

I am currently in the process of creating a Nuget package for Xamarin Forms, which has been going great. Here is the repo. I have gotten it fully working no issues.

I have also been testing it by including it as a project reference in another, closed source, repo. And this has also been working perfectly fine.

However, I decided to switch from using the project reference to using the actual Nuget, since I was no longer tinkering with the code on the fly to make it work correctly, and I have hit a wall.

The moment I include the package, I am given upward of 5000 errors, which are either

(/Users/UserHere/Projects/PopupsError/PopupsError.Android/CSC: Error CS1703: Multiple assemblies with equivalent identity have been imported: /Users/UserHere/.nuget/packages/awaitablepopups/0.2.5/lib/netstandard2.0/System.Xml.XmlSerializer.dll' and /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/Facades/System.Xml.XmlSerializer.dll. Remove one of the duplicate references. (CS1703) (PopupsError.Android))

or

(/Users/UserHere/Projects/PopupsError/PopupsError.Android/Resources/Resource.designer.cs(36,36): Error CS0731: The type forwarder for type 'System.Attribute' in assembly 'netstandard' causes a cycle (CS0731) (PopupsError.Android))

And a multitude of others, I have a completely fresh repo with just the Nuget added here

The bit that is most confusing to me, is that the same exact project works as a project reference, but if I make it a Nuget and add it in, then it throws the error seen above.

I am under the impression, that its some small option I could add, but after some research, I am unable to figure out what small option I should tick. Any help would be greatly appreciated

All answers to this question, which has the identifier 60822872

The best answer:

This is sometimes headache.

For local projects migrating from packages.config to PackageReference

You have to go and delete duplicate nuget from physical disk.

Delete this folder /Users/UserHere/.nuget/packages/awaitablepopups/0.2.5/lib/netstandard2.0

Since you mentioned you moved from packages.config to PackageReference within csproj file, you have to be also careful that csproj still doesnt have old style imports , you can fix this by comparing your csproj file with newly created project csproj file as reference.

Delete and remove "package.config" and 'app.config` reference from csproj file as well.

Update

For NuGet

  • Check .nuspec file and remove reduntant imports
  • Clean the project , delete bin obj folders manually as well.
  • Remove NuGet.Build.Packaging , its not required. Its adding all of those reduntant assemblies.

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data