Say I have a Visual Studio 2015 solution with two projects, MyApp
(.NET) and MyLib
(Portable--targeting .NET 4.6 and UWP 10). It compiles and runs fine.
Then I add any NuGet package to MyLib
--could be anything, but let's just pick Rx-Main just as an example. I add a simple line of code in a MyLib
class that makes use of an Rx type.
Now MyApp
will crash upon startup with a FileNotFoundException citing the nuget package dll. By adding the same NuGet package to MyApp
solves the issue.
Why is it necessary to add the NuGet package to the application project as well?
If MyLib
was a normal .NET project this would not be necessary.
EDIT Some clarification is needed...
In a standard .NET class library project, all the NuGet packages show up as individual DLLs under References:
They each have a dozen properties that can be edited in the Properties window, including Copy Local
:
In a PCL project, under References, the NuGet packages have no properties whatsoever, and no way to have them copied to the output directory.
There are at least two problems with this situation:
- It only rears its ugly head at runtime (FileNotFoundException), not compile time.
- Now every client of that PCL project is forced to deal with all the dependencies of that PCL, whereas before it was cleanly transparent.