3

We create and host NuGet packages in-house, with source code and deep dependency trees. I'm having some issues getting dependencies to "behave".

For clarity, this is specifically installing packages via VS or Rider into a .Net Core / PackageReference project. I don't expect it to be a VS/Rider/etc bug, so much as we're doing something slightly wrong.

Scenario:

  • Create “Package A” using the PackageReference style compilation of “contentFiles/any/any”.
    • Create a sub-folder under “contentFiles/any/any” called “Source”.
    • Place source code files in the “Source” folder.
    • Have a dependency on “Package B”.
  • Create “Package B”, again using the PackageReference style, with a “Source” subfolder.
    • Place source code files in its “Source” folder.
  • Pack and publish both.

Expectation:

  • Install “Package A” (using the built-in NuGet package manager UI).
    • Your project gains a “Source” folder.
    • A’s source files are referenced into the new “Source” folder and compile with the project.
    • “Package B” is also installed, since it’s a dependency.
    • B’s source files are also referenced into the “Source” folder and compile with the project.
  • Package A is immediately consumable by the project because all of its code, and all of its dependency’s code, is present.

Actual:

  • Install “Package A”.
    • Your project gains a “Source” folder.
    • A’s source files are referenced into the new “Source” folder and compile with the project.
    • “Package B” is also installed, since it’s a dependency.
    • B’s source files are not referenced into the “Source” folder.
    • Package A code cannot be compiled because the source for B is not in the project.
  • Manually install “Package B”, same as you did for “A”.
    • B’s source files are referenced into the new “Source” folder in the project.
    • Now “Package A” can be compiled and consumed.

If sample nuspec files are needed, etc. please let me know.

Thanks

(This is a cross-post from https://github.com/NuGet/Home/issues/8858. No replies for a week)

1 Answer 1

0

The post to NuGet's github (listed above) ended up with the solution. When declaring the dependency in the nuspec, set the include to "Runtime,Compile,Native,ContentFiles,BuildTransitive" (or some combination thereof) and your dependency's files will correctly embed. I'm still working through the differences between the options, but there you have it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.