2

I need to reference two assemblies, both of them contain the same type. The answer from Type exists in 2 assemblies would be useful, but I'm using PackageReference not packages.config and references. Package reference doesn't have the alias option:

<PackageReference Include="<package-id>" Version="" PrivateAssets="" IncludeAssets="" ExcludeAssets="" />

Is there any other way?


Example:

Create a new Console .NET 4.6.1 app. Change default package management format to PackageReference in Options > NuGet Package Manager > General. Add two NuGet packages: 'squirrel.windows' and 'NuGet.Core' (required for 'NuPlug').

var pm = new NuGet.PackageManager()
J2ghz
  • 632
  • 1
  • 7
  • 20
  • And what is a issue? You want to reference two different assemblies which have different names but the same types, so if you have issue in the code when compiler cannot determine what type should use you can add alias to namespace and refer to type by namespace alias. Did I understand your question correct? – George Alexandria Sep 21 '17 at 21:11
  • Yes, my issue is the same as https://stackoverflow.com/a/17651003/4363604 and solution would be the same except I don't know how to use alias with PackageReference – J2ghz Sep 22 '17 at 07:50
  • I mean that you can reference to both assemblies and in the code use something looks like this `using Dll_1.SameType; using anotherSameType = Dll_2.SameType; ... var obj = anotherType.SomeObj();`. Can you do that? – George Alexandria Sep 22 '17 at 19:24
  • I can't, because even though they are in different assemblies, the namespace and type is the same – J2ghz Sep 22 '17 at 21:06
  • just wait https://github.com/NuGet/Home/issues/4989 – psmolkin Sep 29 '17 at 20:56

0 Answers0