【问题标题】:ASP.NET Core doesn't create XML comments fileASP.NET Core 不创建 XML 注释文件
【发布时间】:2017-08-01 03:03:32
【问题描述】:

我正在为 Api 文档使用 Swashbuckle,它需要输出中的 projectname.xml 文档,但是当我构建我的 ASP.NET Core 项目时,我没有得到那个文件。

https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger

Visual Studio 可以选择生成 XML 文件,但我如何从控制台执行此操作?

这是我的 ASP.NET Core 版本:

.NET Command Line Tools (1.0.0-preview2-1-003177)

【问题讨论】:

    标签: visual-studio asp.net-core


    【解决方案1】:

    对于 Visual Studio 2017 和 dotnet CLI,在 .csproj 文件中设置 DocumentationFile 属性将在相对于项目文件的指定路径生成 XML 文档。例如,要在与您构建的程序集相同的目录中生成 XML 文档,您可以将以下属性组添加到项目文件中:

    <PropertyGroup>
      <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\MyProject.xml</DocumentationFile>
    </PropertyGroup>
    

    如果您只想为特定配置或平台构建它,请确保在属性组上设置适当的Condition

    【讨论】:

      【解决方案2】:

      如果你还在使用 Visual Studio 2015,你可以在 project.json 中添加 xmlDocbuildOptions 来完成

      "buildOptions": {
          "xmlDoc": true,
      }
      

      Visual Studio 2017(*.csproj 结构)我不确定。但是当您通过 Visual Studio 设置它时,它将被保存在 csproj/project.json 文件中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-09
        • 2020-04-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多