How to generate XML documentation for CSPROJ with multiple targets

前端 未结 2 1907
无人及你
无人及你 2020-12-29 23:00

I have a library project that has multiple targets, e.g. in the CSPROJ file it has:

net40;net46;net461;net462;net47

        
相关标签:
2条回答
  • 2020-12-29 23:18

    An easy way is to set the GenerateDocumentationFile property to true. The VS UI want to set the path, the MSBuild targets will set this property to true if the path is set or set a default path if the GenerateDocumentationFile property is true. So you can add this to your csproj file:

    <PropertyGroup>
      <GenerateDocumentationFile>true</GenerateDocumentationFile>
    </PropertyGroup>
    

    If you want to set this to true for all your projects to share it, create a file named Directory.Build.props in your solution's directory with the following content and it will be auto-imported into any projects in the directory hierarchy below:

    <Project>
      <PropertyGroup>
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
      </PropertyGroup>
    </Project>
    
    0 讨论(0)
  • 2020-12-29 23:30

    One way to fix this is to include the following in each CSPROJ file:

    <!-- Build XML documentation for all combinations of target framework x configuration -->
    <PropertyGroup>
     <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml 
     </DocumentationFile>
    </PropertyGroup>
    

    An even better way is to link to a shared configuration file:

    <!-- This must come after any other configuration so that it overwrites it -->
    <Import Project="$(MSBuildThisFileDirectory)..\Shared.msbuild" />
    

    ... and then place the above lines in that shared configuration file where you can also set all the other solution-wide CSPROJ settings like Product, Company, Copyright, ...

    0 讨论(0)
提交回复
热议问题