Search code examples
visual-studio-2017nuget.net-standard-2.0opc-ua.net-4.7.2

.net 4.7.2 library referencing standard 2.0 NuGetPackage does not work


I need to use the NuGet package OPCFoundation.NetStandard.Opc.Ua in a .NET Framework 4.7.x class library.

So far my class library was .NET Framework 4.7.0. It worked OK, although the OPCFoundateion.NetStandard.Opc.Ua package (.NET Standard 2.0) generated a HUGE bunch of shim system DLLs in the bin folder. Not good at all, but it worked.

Because I found all those dozens of shim dll's very annoying I made some research. According to various articles I learned that all those DLLs should go away once I upgrade my class library to version 4.7.2.

Well so I did, but things only got worse.

If you try this:

  1. Create a brand new solution (VS2017, fully updated)
  2. Create a blank 4.7.2 class library
  3. Import the OPCFoundation.NetStandard.Opc.Ua package into the class library

the following happens:

  • Still 83 system.* (and other) shim packages are being downoaded, installed and stored in the Packages folder

  • 25 warnings pop up, saying: "The referenced component 'System.xxxx.xxxx' could not be found"

If I ignore those warnings and try to use the package nevertheless, I get runtime exceptions saying that various DLLs are missing.

What is going on? Why doesn't it work with 4.7.2 while it works with 4.7.0?

I urge you to try it out for yourself, it is very, very easy to reproduce.

I use packages.config for NuGet handling, mainly because I cannot get our TeamCity build server build the project if I use packageReferences.


Solution

  • .net 4.7.2 library referencing standard 2.0 NuGetPackage does not work

    This is a known issue Issues with .NET Standard 2.0 with .NET Framework & NuGet, those warning messages were added from .net framework 4.7.1 by MS to remind the user to know that this issue exists. That is the reason why it does not work with 4.7.2 while it works with 4.7.

    But the warnings are innocuous and merely present in the IDE, but may be annoying.

    To resolve those warnings, you can remove those System.* references from your project, since you can not use packageReferences.

    See Adding .NET Standard libraries to 4.7.1 lib adds loads of references, some broken for some more info:

    Hope this helps.