繁体   English   中英

如何为具有多个目标的CSPROJ生成XML文档

[英]How to generate XML documentation for CSPROJ with multiple targets

我有一个具有多个目标的库项目,例如它在CSPROJ文件中:

<TargetFrameworks>net40;net46;net461;net462;net47</TargetFrameworks>

如果我想要这些目标框架和DebugRelease配置的所有组合的XML文档,我必须使用Build Configuration Manager在UI中依次选择每个文档,然后将其设置为为该组合构建XML文档,然后列出每个组合单独作为CSPROJ中的PropertyGroup以及XML文档的预期输出文件。

有没有更好的办法?

发布问题和答案,因为我没有在网上找到其他任何记录

一种简单的方法是将GenerateDocumentationFile属性设置为true。 VS UI要设置路径,如果路径设置,MSBuild目标将此属性设置为true,或者如果GenerateDocumentationFile属性为true,则设置默认路径。 所以你可以将它添加到你的csproj文件中:

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

如果要将所有项目设置为true以进行共享,请在解决方案的目录中使用以下内容创建名为Directory.Build.props的文件,并将其自动导入到以下目录层次结构中的任何项目中:

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

解决此问题的一种方法是在每个CSPROJ文件中包含以下内容:

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

更好的方法是链接到共享配置文件:

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

...然后将上面的行放在该共享配置文件中,您还可以在其中设置所有其他解决方案范围的CSPROJ设置,如ProductCompanyCopyright ,...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM