NuGetForUnity: Nuget for Unity installs too many packages

Description

Nuget for Unity installs too many packages. Aside from the package I want to install, it also installs packages from the System namespace (like System.IO, System.Linq, System.Collections, etc.), which should not be installed, because obviously those DLLs are already present.

Because of the installation of those additional DLLs, Unity complains about “Multiple assemblies with equivalent identity”.

The full content of the packages.config file after I installed only the one package mentioned below:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Castle.Core" version="4.4.0" />
  <package id="Microsoft.NETCore.Platforms" version="1.1.0" />
  <package id="Microsoft.NETCore.Targets" version="1.1.0" />
  <package id="Microsoft.Win32.Primitives" version="4.3.0" />
  <package id="Moq" version="4.15.1" />
  <package id="NETStandard.Library" version="1.6.1" />
  <package id="runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.native.System" version="4.3.0" />
  <package id="runtime.native.System.IO.Compression" version="4.3.0" />
  <package id="runtime.native.System.Net.Http" version="4.3.0" />
  <package id="runtime.native.System.Security.Cryptography.Apple" version="4.3.0" />
  <package id="runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple" version="4.3.0" />
  <package id="runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="System.AppContext" version="4.3.0" />
  <package id="System.Buffers" version="4.3.0" />
  <package id="System.Collections" version="4.3.0" />
  <package id="System.Collections.Concurrent" version="4.3.0" />
  <package id="System.Collections.NonGeneric" version="4.3.0" />
  <package id="System.Collections.Specialized" version="4.3.0" />
  <package id="System.ComponentModel" version="4.3.0" />
  <package id="System.ComponentModel.Primitives" version="4.3.0" />
  <package id="System.ComponentModel.TypeConverter" version="4.3.0" />
  <package id="System.Console" version="4.3.0" />
  <package id="System.Diagnostics.Debug" version="4.3.0" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.3.0" />
  <package id="System.Diagnostics.Tools" version="4.3.0" />
  <package id="System.Diagnostics.TraceSource" version="4.3.0" />
  <package id="System.Diagnostics.Tracing" version="4.3.0" />
  <package id="System.Dynamic.Runtime" version="4.3.0" />
  <package id="System.Globalization" version="4.3.0" />
  <package id="System.Globalization.Calendars" version="4.3.0" />
  <package id="System.Globalization.Extensions" version="4.3.0" />
  <package id="System.IO" version="4.3.0" />
  <package id="System.IO.Compression" version="4.3.0" />
  <package id="System.IO.Compression.ZipFile" version="4.3.0" />
  <package id="System.IO.FileSystem" version="4.3.0" />
  <package id="System.IO.FileSystem.Primitives" version="4.3.0" />
  <package id="System.Linq" version="4.3.0" />
  <package id="System.Linq.Expressions" version="4.3.0" />
  <package id="System.Net.Http" version="4.3.0" />
  <package id="System.Net.Primitives" version="4.3.0" />
  <package id="System.Net.Sockets" version="4.3.0" />
  <package id="System.ObjectModel" version="4.3.0" />
  <package id="System.Reflection" version="4.3.0" />
  <package id="System.Reflection.Emit" version="4.3.0" />
  <package id="System.Reflection.Emit.ILGeneration" version="4.3.0" />
  <package id="System.Reflection.Emit.Lightweight" version="4.3.0" />
  <package id="System.Reflection.Extensions" version="4.3.0" />
  <package id="System.Reflection.Primitives" version="4.3.0" />
  <package id="System.Reflection.TypeExtensions" version="4.3.0" />
  <package id="System.Resources.ResourceManager" version="4.3.0" />
  <package id="System.Runtime" version="4.3.0" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" />
  <package id="System.Runtime.Extensions" version="4.3.0" />
  <package id="System.Runtime.Handles" version="4.3.0" />
  <package id="System.Runtime.InteropServices" version="4.3.0" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" />
  <package id="System.Runtime.Numerics" version="4.3.0" />
  <package id="System.Security.Cryptography.Algorithms" version="4.3.0" />
  <package id="System.Security.Cryptography.Cng" version="4.3.0" />
  <package id="System.Security.Cryptography.Csp" version="4.3.0" />
  <package id="System.Security.Cryptography.Encoding" version="4.3.0" />
  <package id="System.Security.Cryptography.OpenSsl" version="4.3.0" />
  <package id="System.Security.Cryptography.Primitives" version="4.3.0" />
  <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" />
  <package id="System.Text.Encoding" version="4.3.0" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" />
  <package id="System.Text.RegularExpressions" version="4.3.0" />
  <package id="System.Threading" version="4.3.0" />
  <package id="System.Threading.Tasks" version="4.3.0" />
  <package id="System.Threading.Tasks.Extensions" version="4.5.1" />
  <package id="System.Threading.Timer" version="4.3.0" />
  <package id="System.Xml.ReaderWriter" version="4.3.0" />
  <package id="System.Xml.XDocument" version="4.3.0" />
  <package id="System.Xml.XmlDocument" version="4.3.0" />
</packages>
  • NuGet Package: Moq, 4.15.1
  • NuGetForUnity Version: 2.0.0
  • Unity Version: 2020.1.6f1
  • Operating System: Win 10, 64 bit

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Yeah, I will try to make PR for that in next few days.

At this line you can see where we’re deleting subfolders of the Nuget “lib” folder based on the “best” target framework for the given settings. Around this point in the code I think we should:

  1. Use this same “best” target framework and the idea above to scour the Unity install directory for dlls that Unity already provides for that “best” target framework.
  2. Look in the selected lib directories that we’re keeping and delete any dlls that Unity is already providing.

Does that make sense?

I believe we can use EditorApplication.applicationPath to get the path to the currently running Unity executable.