我对netstandard库的使用有疑问:
假设我有UWP项目。该项目允许在1.4及以下版本中安装netstandard库。我正在使用netstandard 1.2版创建PCL库,并添加此库作为UWP项目的参考。我正在为PCL库添加一些nuget包。这个nuget也是netstandard 1.2版本。
我错过了什么或它应该那样工作?
所描述的问题基于通用Windows平台,但我认为问题更为普遍,而不是使用此平台。
答案 0 :(得分: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.
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.