raV720
raV720

Reputation: 605

Netstandard libraries - referencing in portable classes

I have a questions about usage of netstandard libraries:

Assume I have UWP project. This project allows to install netstandard library in version 1.4 and below. I am creating PCL library with netstandard version 1.2 and add this library as reference to UWP project. I am adding some nuget package to PCL library. This nuget is also in netstandard 1.2 version.

  1. Can I use nuget package from UWP project without adding reference to it? I have read somewhere that I can, but I can't get it working on my own.
  2. If I use nuget package only from created PCL library then everything builds ok, but during runtime it turns out that PCL throws exception that cannot find referenced nuget library. The nuget is not copied to final bin directory, so it cannot be found. How to handle that? Should I reference this library from UWP project?
  3. If I add nuget reference to UWP project then the actual referenced nuget may differ from library referenced from PCL library, because nuget.org may return different libraries for UWP project and dfifferent PCL netstandard1.2 library. So during runtime PCL library will find referenced dll but this dll is not in apriopriate version.

Am I missing something or it should work like that?

The described problem is based on universal windows platform but as I think the problem is more general, not with this platform.

Upvotes: 1

Views: 284

Answers (1)

Elvis Xia - MSFT
Elvis Xia - MSFT

Reputation: 10841

Can I use nuget package from UWP project without adding reference to it? I have read somewhere that I can, but I can't get it working on my own.

As far as I know, it is not possible to use a Nuget package without adding reference to it. Nuget simply add a reference to these external packages in the .nuspec file. If you don't want to use nuget package, you can directly reference the libraries. You can find the libraries under C:\Users\<username>\.nuget\packages\<Destination Package>

If I use nuget package only from created PCL library then everything builds ok, but during runtime it turns out that PCL throws exception that cannot find referenced nuget library. The nuget is not copied to final bin directory, so it cannot be found. How to handle that? Should I reference this library from UWP project?

It could be caused by a variety of reasons. Could you please offer some steps to reproduce this problem?

If I add nuget reference to UWP project then the actual referenced nuget may differ from library referenced from PCL library, because nuget.org may return different libraries for UWP project and dfifferent PCL netstandard1.2 library. So during runtime PCL library will find referenced dll but this dll is not in apriopriate version.

Please update the the library in PCL to the same version.

Upvotes: 1

Related Questions