Skip to content

How to reference dll and xml files from nuget package as a documentation source #769

@StevenBonePgh

Description

@StevenBonePgh

This is more of a best-practices question, and perhaps an attempt to determine if a better way to do this could be discovered. I have a class that is inherited from a class found in a nuget package. As per your guidance, I created a 'child' documentation project that is not built, but is rather configured in the main project as an Additional Reference Links plug-in with all the link types set to None. As an aside, it is Newtonsoft.Json and it has sample code blocks that cannot be resolved so I added the code block component and allowed missing souce code files/regions. This all works well.

The best practices question is how to properly reference the path to the nuget package contents to add it as a documentation source for the child SHFB project to consume.

There are two options that I see to accomplish this right now:
Option 1
Reference the nuget package path. Issues with this is this path may differ based on nuget configuration, and secondly, is brittle in that updating the package version requires a manual modification. In the ChildShfbProject.shfbproj I have an example of using this approach: <DocumentationSource sourceFile="%USERPROFILE%\.nuget\packages\newtonsoft.json\6.0.5\lib\net45\Newtonsoft.Json.dll" xmlns="" />
Option 2
Use the build process of the assembly being documented, via a post build step, to copy these references from the build output to a static known folder, and configure that to be the location for the documentation source. This is less brittle, but still has issues/concerns:

  • If a multi-target project, would need to handle the case to only copy dependencies for the SHFB target framework.
  • Depends on SHFB and when it processes the child project. My assumption is this would be done after assuring the build of the main project documentation sources is complete, in which case we can rely on the files being there.
  • Visual Studio SDK projects (and probably classic projects using PackageReference) do not copy the .xml files from the nuget lib source folder to the output directory. This behavior has been under heavy discussion here: New project system doesn't copy PDBs from packages dotnet/sdk#1458 (comment)
  • While the above three issues/concerns have workarounds, it requires superhuman understanding to maintain/understand. I need to understand the help doc build depends on custom build steps, injection of an 'AfterTarget' task, copying of output to a static directory, referencing the dependency properly as a documentation source. This is just yucky and unmaintainable.

This approach can be seen in the ValueTupleSandcastleDemo.csproj file (The two 'Target' elements) and in the ChildShfbProject.shfbproj where the path to these outputs is referenced. This example can be found in the zip I attached to an unrelated issue: #763 (comment)

Possible Alternate
Perhaps something kind of like #748 where Tom proposes some integration with the build pipeline of nuget restore. It may be possible to determine the package path, use that to set a variable (perhaps package name), and that variable would be available to use as part of the DocumentationSource element. This would be brittle in terms of package versions, since the packages in SHFB projects don't appear in Visual Studio Nuget manage packages for solution, but this is the only path I can see. Unless I am missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions