我认为通常优良做法是将包含在NuGet包中的C#build生成的XML文档文件与DLL一起包含,以便为消费者提供智能感知文档。
但是,我不清楚在使用VS 2017的项目文件格式构建软件包时如何做到这一点。
这可能吗?
显然我可以切换到维护一个nuspec文件,但VS2017格式非常方便将版本和依赖项保存在一个地方。
答案 0 :(得分:16)
只要在csproj文件中设置x[date > Sys.Date() - 50]
,就像这样:
GenerateDocumentationFile
然后所有默认值都会在正确的位置生成文档文件,它将包含在NuGet包中。
如果Visual Studio添加了<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
</Project>
或其他元素,您可以删除它们并将其替换为单个DocumentationFile
属性。
答案 1 :(得分:0)
对于其他遇到相同问题的人-如果接受的答案没有帮助...
确保已在使用的构建配置中设置了“包括XML文档”设置(默认情况下,不仅是“调试”)
或在csproj中:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
答案 2 :(得分:0)
我发现仅将GenerateDocumentationFile
设置为true
会生成一个名为.xml
的文件(注意,只是扩展名,没有文件名)。因此,我发现最好按以下步骤进行操作:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>