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: 3 comments 8 replies
-
|
Don't use the |
Beta Was this translation helpful? Give feedback.
-
|
@zivkan This error message tripped me up too. Can you please clarify whether |
Beta Was this translation helpful? Give feedback.
-
|
@zivkan , I've encountered the following behavior and I am wondering if you can clarify if this is the intended behavior or not: Let's say I have a nuget package that contains 3 dlls: Based on the documentation and examples, I would believe that the correct format of the Nuget package would be as follows:
What I've found is that if another project uses this Nuget package, it will compile as expected. However, at runtime on a Windows x64 machine, the only assembly that will be found is The other assemblies are copied correctly to the expected locations in the Effectively, there is no "fallback" to the executable's folder for Is this the intended behavior? |
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.