DoomerDGR8
DoomerDGR8

Reputation: 5042

How to figure out the main issue in a Nuget Package

I recently updated my packages and I started to get this weird warning in a few projects. I'm unable to resolve it:

Found conflicts between different versions of "System.Runtime.CompilerServices.Unsafe" that could not be resolved.
There was a conflict between "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
    "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
    References which depend on "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll].
        C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll
          Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll".
            C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll
    References which depend on "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
        C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll
          Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll".
            C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll
            C:\Users\0000\.nuget\packages\system.collections.immutable\5.0.0\lib\net461\System.Collections.Immutable.dll
            C:\Users\0000\.nuget\packages\nito.disposables\2.2.1\lib\net461\Nito.Disposables.dll
            C:\Users\0000\.nuget\packages\nito.asyncex.context\5.1.2\lib\net461\Nito.AsyncEx.Context.dll
            C:\Users\0000\.nuget\packages\nito.asyncex.coordination\5.1.2\lib\net461\Nito.AsyncEx.Coordination.dll
            C:\Users\0000\.nuget\packages\nito.asyncex.oop\5.1.2\lib\net461\Nito.AsyncEx.Oop.dll
            C:\Users\0000\.nuget\packages\nito.asyncex.tasks\5.1.2\lib\net461\Nito.AsyncEx.Tasks.dll
            C:\Users\0000\.nuget\packages\nito.asyncex.interop.waithandles\5.1.2\lib\net461\Nito.AsyncEx.Interop.WaitHandles.dll
            C:\Users\0000\.nuget\packages\nito.cancellation\1.1.2\lib\net461\Nito.Cancellation.dll
        C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
          Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll".
            C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
            C:\Users\0000\.nuget\packages\utf8json\1.3.7\lib\net47\Utf8Json.dll
            C:\Users\0000\.nuget\packages\easy.logger.extensions\1.5.0\lib\net45\Easy.Logger.Extensions.dll Focus.Tests.LogicTester

How do I decipher what is the actual issue here? Is there a package that internally depend on a specific version of a DLL but that DLL is also addedd directly with a newer version?

Upvotes: 1

Views: 1343

Answers (1)

Jimmy
Jimmy

Reputation: 28386

In short, you have dependencies on two different versions of the same DLL. Breakdown below, but TL;DR, you should be able to resolve this by updating your PackageReference to System.Runtime.CompilerServices.Unsafe to version 6.0.0.

If you don't call into it directly, consider removing the PackageReference, as it should be added transitively via the other references listed below.

If you don't have a PackagerReference to this package, adding one (using version 6.0.0) would make that the primary reference, thereby again aligning everything at the same version.

Error message breakdown:

Found conflicts between different versions of "System.Runtime.CompilerServices.Unsafe" that could not be resolved.
There was a conflict between "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

The compiler picked one based on some measure of how directly you referenced it (as opposed to one of your dependencies referencing it):

"System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.

The 5.0 version is referenced by:

References which depend on "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll].
    C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll

The item in the project that creates this runtime dependency on the 5.0 file seems to be itself, i.e. you reference it directly:

Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll".
  C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll

The 6.0 version is referenced by these dependencies:

References which depend on "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
    C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll
      ...
    C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
      ...

These are indirectly referenced via other packages:

Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll".
  C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll
  C:\Users\0000\.nuget\packages\system.collections.immutable\5.0.0\lib\net461\System.Collections.Immutable.dll
  C:\Users\0000\.nuget\packages\nito.disposables\2.2.1\lib\net461\Nito.Disposables.dll
  C:\Users\0000\.nuget\packages\nito.asyncex.context\5.1.2\lib\net461\Nito.AsyncEx.Context.dll
  C:\Users\0000\.nuget\packages\nito.asyncex.coordination\5.1.2\lib\net461\Nito.AsyncEx.Coordination.dll
  C:\Users\0000\.nuget\packages\nito.asyncex.oop\5.1.2\lib\net461\Nito.AsyncEx.Oop.dll
  C:\Users\0000\.nuget\packages\nito.asyncex.tasks\5.1.2\lib\net461\Nito.AsyncEx.Tasks.dll
  C:\Users\0000\.nuget\packages\nito.asyncex.interop.waithandles\5.1.2\lib\net461\Nito.AsyncEx.Interop.WaitHandles.dll
  C:\Users\0000\.nuget\packages\nito.cancellation\1.1.2\lib\net461\Nito.Cancellation.dll
...
Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll".
  C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
  C:\Users\0000\.nuget\packages\utf8json\1.3.7\lib\net47\Utf8Json.dll
  C:\Users\0000\.nuget\packages\easy.logger.extensions\1.5.0\lib\net45\Easy.Logger.Extensions.dll Focus.Tests.LogicTester

Upvotes: 3

Related Questions