Clarification of lib vs ref & runtimes folders #11097
-
I'm hoping someone can clarify the correct usage of the /lib/ folder vs /ref/ and /runtimes/ folders. I have a project that targets a couple of platforms, (eg: win and osx). The public api to is identical on all platforms, but the implementation on each is very different. eg: the windows build pinvokes to Win32, while the osx build uses ObjC interop. From this documentation it sounds like the /lib/ folder should be used for platform independent assemblies and platform specific libraries the /ref/ folder should be used for compile time references and the /runtimes/ folder for the per-platform implementation assemblies. In other words you should use either:
So, I would expect this should work:
But, when building the package I get the following errors:
Why? Shouldn't the files /ref and /runtimes suffice? What would the assembly in the root /lib/ folder be used for and wouldn't putting the assembly in the /lib/ folder result in the wrong assembly being used on unsupported target platforms? Also:
And finally, and perhaps most interestingly I tried this:
Seems like nuget's error message is wrong and should allow empty /lib/ folder if there's /ref and /runtimes folders. Am I missing something? Is there a work around for this? Any help greatly appreciated. Using: nuget.exe version 5.10.0.7240 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Don't use the |
Beta Was this translation helpful? Give feedback.
Don't use the
<references>
section in the metadata. That's a packages.config-era feature, whereas the top level ref and runtimes folders are PackageReference only. In other words,<references>
only works inlib/
, which is where I expect the error is coming from. In PackageReference, assets underruntimes/
are never passed to the compiler, whereas assets underref/
are only passed to the compiler, never copied to the output folder.