How to properly specify DocumentationFile in MsBuild 15 .csproj with multitargeting

503 Views Asked by At

I am using the latest preview of MsBuild 15 and I have a multitarget project file targeting both net40 and netstandard1.6. I am struggling with specifying <DocumentationFile> correctly.

For any path I would specify, the resultant xml file after the build will be both in that path and two target output directories.

For instance, if I specify <DocumentationFile>doc.xml</DocumentationFile>

Then the xml file will be generated both in my project dir and bin\net40 and bin\netstandard1.6.

I need those xml documentation files only in my bin\net40 and bin\netstandard1.6 directories. How can I achieve that? Also, with the current behavior, it is not clear which documentation file is copied to my project dir, because those xml documents can differ for two targets.

In earlier project versions I used to specify documentation xml path separately for Debug and Release build configurations with paths like bin\Debug\doc.xml, but with the newest MsBuild 15 it is possible to do multitargeting and the number of such paths double if I specify the dir for all possible combinations of target and build configuration.

Is there any generic good way to specify documentation file path once and get it to the right output places only?

1

There are 1 best solutions below

0
On

From my testing if you specify

<DocumentationFile>bin\Debug\netstandard1.0\MyProjectName.xml</DocumentationFile>

it will create doc file in each multi-targeted folder so it'll create

  • netstandard1.0\MyProjectName.xml
  • net45\MyProjectName.xml
  • netcoreapp1.0\MyProjectName.xml
  • netstandard2.0\MyProjectName.xml

etc.