3

I am hoping to add the auto-generated XML documentation file produced by Visual Studio to my project's Assembly as an Embedded Resource, but I am uncertain how to go about this. I am aware that I can manually alter the .csproj file to add resources, using something like:

<EmbeddedResource Include="Path\To\File\MyEmbeddedResource.meta.xml">
    <Link>MyEmbeddedResource.meta.xml</Link>
</EmbeddedResource>

But I don't know how that interacts with the Build procedure, or what path I would provide for the XML file, given that it itself is placed in the build folder?

I know I can use the above snippet to add an arbitrary file as an embedded resource for the .dll, but how do I ensure that the documentation file is up to date, and uses the one generated in the most recent build?

The overall goal here is to have the documentation accessible via reflection, such that the .dll has fewer external file dependencies. Given that the project itself is a Class Library, I would hope that any answer doesn't break when the Assembly is included in another project.

Gebodal
  • 345
  • 2
  • 12

1 Answers1

0

The embedded resource file is not placed in the build output folder, it is included in the binary output of the DLL file. Like you would define a public constant string whose content is the XML file's content. But embedded resources can be accessed via solution of https://stackoverflow.com/a/3314213/593045

The resouceName depends in which subfolders you place the XML file and how you call it - that defines the resource name. So I would use a base folder e. g. "embeddedXmlDoc" and inside that an identical structure of folders (a folder for each text between . in namespaces) like the classes and its namespaces you want to document. Then you could find the right file just by using their namespace and class name.

BitLauncher
  • 587
  • 4
  • 15
  • 2
    Apologies, I don't think I was clear enough, so I've edited it to be more precise. The problem isn't how to add a file as an Embedded Resource, I know how to do that. The question is how do you embed the auto-generated documentation file, such that it's always up to date, without having to Build the project a second time using the previously generated XML. For all I know, the build procedure happens in the correct order for this anyway (so the XML file is generated before the `.dll`), but I was hoping someone could verify this, or tell me how to make sure it happens in that order. – Gebodal Jun 26 '20 at 21:20