简体   繁体   English

如何使用.net核心Web应用程序发布XML文档?

[英]How can I publish XML documentation with a .net core web application?

In the csproj file I've enabled XML documentation generation via the following tag: 在csproj文件中,我通过以下标记启用了XML文档生成:

  <PropertyGroup>
    <DocumentationFile>bin\xml\Project.Api.xml</DocumentationFile>
    <NoWarn>1701;1702;1705;1591;1573</NoWarn>
  </PropertyGroup>

This works and correctly builds xml docs. 这适用于并正确构建xml文档。 Now I need this XML file to be distributed with the application (for Swagger support among other things). 现在我需要将这个XML文件与应用程序一起分发(对于Swagger支持等)。 So I added the following: 所以我添加了以下内容:

  <ItemGroup>
    <None Update="bin\xml\Project.Api.xml">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>      
    </None>
  </ItemGroup>

However, when I publish to a folder (or to azure) the XML doc is no where to be found. 但是,当我发布到文件夹(或azure)时,XML文档无处可寻。

What am I missing? 我错过了什么?

The following works for me in your scenario (at least when publishing to folder): 以下适用于您的场景(至少在发布到文件夹时):

  <!-- Run before PrepareForPublish target -->
  <Target Name="CopyDocumentationFile" BeforeTargets="PrepareForPublish">
    <ItemGroup>      
      <DocFile Include="$(DocumentationFile)" />
    </ItemGroup>
    <!--just copy doc file to target location -->
    <Copy SourceFiles="@(DocFile)" DestinationFolder="$(PublishDir)" SkipUnchangedFiles="true" />
  </Target>

Here you can find docs about how to include custom files into publish output in general. 在这里,您可以找到有关如何将自定义文件包含到发布输出中的文档。 They use more complicated way, but just a little bit more. 他们使用更复杂的方式,但只是更多一点。

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

相关问题 如何在开发中将ASP.Net Core Web Api发布到HTTP而不是HTTPS? - How can I publish an ASP.Net Core Web Api to HTTP instead of HTTPS in development? 如何仅以英文发布 .NET 核心应用程序? - How to publish a .NET Core application in English only? 无法发布.NET Core Web Application(无法加载文件或程序集Microsoft.DotNet.ProjectModel) - Can't publish .NET Core Web Application (could not load file or assembly Microsoft.DotNet.ProjectModel) 如何将已登录的用户重定向到 Asp.Net Core web 应用程序中的索引(剃须刀页面) - How can I redirect an already logged user to Index in Asp .Net Core web Application (razor pages) 在我的 asp.net 核心 MVC web 应用程序中,我如何使验证码成为必填字段 - Inside my asp.net core MVC web application how i can make the recaptcha a required field 如何为 .net 核心 MVC Web 应用程序创建和显示 PDF 文件? - How can I create and display a PDF file for a .net core MVC web application? 无法在本地iis上发布.net Core Web API - Can't publish .net core web api on local iis 如何在多台服务器上发布 Web API net core 3.0 - How to Publish a Web API net core 3.0 in multiple servers 如何将 .Net Core Web Api 从 VS Code 发布到 Azure? - How to publish a .Net Core Web Api from VS Code to Azure? 我如何在核心2.1(系统文件)中发布Web API - How can I publish my web api in core 2.1 (System Files)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM