Reputation: 381
With the coming of netstandard, it should be easier to create libraries that can be used in both netcore and netframework. There's also the possibility to add multiple target frameworks to a netstandard library, so that it can be built for more than one target. However, there's something in this that doesn't feel right to me somehow and maybe I am seeing it the wrong way. I'll try my best to explain the scenario.
I have this netstandard library, targeting netstandard1.5 and net461. I did this by changing the project to and by adding both targets. This project is being built and packaged into a nuget package, which, by closer inspection, does contain binaries for net461 and netstandard1.5. With this, I assumed i had a library that could be added to a netcore project or to a netframework project, with minimum dependencies. Also, this library dependends on Microsoft.Extensions.Logging.Abstractions (1.1.2), Newtonsoft.Json (10.0.2) and System.Security.SecureString (4.3).
On the other side, I have a classic console project, with netframework 461. And naturally, I will want to use the library here and since it's a netframework 461 project and the library also targets netframework 461, I would think that the dependencies would be kept to a minimumm. When I look for the package, the its dependencies are the ones I expected, but when I go and try to install it, I get flooded with dependencies that I wouldn't think it would be necessary, such as the NETStandard.Library (1.6.2), Microsoft.NETCore.Platforms (1.1.0), System.Runtime (4.3) and all its associates (collections, io, security, etc etc). I would think that I wouldn't need to add all these dependencies, since the library targets netframework, but seems like I'm wrong or something else's wrong.
Could anyone provide some insights on this please?
Upvotes: 1
Views: 177
Reputation: 381
I guess that I'll be answering my own question, which isn't that complicated really.
It turns out that Microsoft.Extensions.Logging targets only netstandard and because of that, requires all the other dependencies.
Once I removed the Microsoft package and rebuilt my own, I was able to add it as a dependency to the netframework project without all the clutter.
Maybe this'll help someone in the future...
Upvotes: 2