VS 2017 WebAPI 帮助页面 - 未提供文档 [英] VS 2017 WebAPI Help Page - No Document Provided

查看:20
本文介绍了VS 2017 WebAPI 帮助页面 - 未提供文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照 MSDN 和其他 SO 问题,以设置文档并在帮助页面的描述部分显示 XML 注释.但是,当我尝试构建或运行项目时收到错误.Visual Studio 2017 在属性中不再有构建"选项.它已被编译"部分取代.虽然此部分确实有生成 XML 文档文件"选项,但它没有 XML 文档文件位置选项(如 MSDN 说明中所述).话虽如此,我们知道 XmlDocumentProvider 正在 HelpPageConfig.vb 文件中寻找~/App_Data/XmlDocument.xml".

I have followed the steps at MSDN, and other SO questions, to setup documenting and to have the XML comments show in the descriptions section of the help page. However, I am receiving errors when I try to build or run the project. Visual Studio 2017 no longer has the "Build" selection in properties. It has been replaced by the "Compile" section. While this section does have the "Generate XML documentation file" option, it does not have a XML documentation file location option (as in the MSDN directions). That being said, we know that the XmlDocumentProvider is looking for "~/App_Data/XmlDocument.xml" in the HelpPageConfig.vb file.

首先,当我运行该项目时,它返回未提供文档"错误,因为那里没有文档.当我在 App_Data 文件夹中创建 XML 文档XMLDocument.xml"时,会返回一条错误消息,提示找不到根元素".添加根元素后,不会返回任何错误;但是,帮助页面中也没有显示说明.

First when I run the project it returns with a "No Document Provided" error, because, well, there is no document there. When I create an XML document "XMLDocument.xml" in the App_Data folder an error returns saying "No Root Element Found." After adding a root element no errors are returned; however, no descriptions show up in the help page either.

设置:

  • 确认 AreaRegistration.RegisterAllAreas() 在 Application_Start 中
  • 未注释 HelpPageConfig.vb 中的 config.SetDocumentationProvider
  • 为所有控制器添加了评论

我试过了:

  • 将复制设置为输出目录:如果更新则复制
  • 各种根元素名称(描述、评论、根等)

有谁知道根元素应该是什么,或者如果文件不存在,是否有办法让 VS 2017 自动生成文件?

Does anyone know what the root element should be, or if there is a way to get VS 2017 to auto-generate the file if it does not exist?

推荐答案

我知道这个答案来得很晚,但我遇到了同样的问题.我无法让 Visual Studio 2017 将 XML 文档文件输出到建议的 ~/App_Data/XmlDocument.xml 位置.

I know this answer comes very late, but I ran into the same problem. I could not get Visual Studio 2017 to output the XML Documentation file to the suggested ~/App_Data/XmlDocument.xml location.

然而,我发现在~/bin/.xml下生成了正确的文件.所以如果你的项目是TestWebAPI2",那么这个文件应该是~/bin/TestWebAPI2.xml.

However, I found that the correct file is generated under ~/bin/<project name>.xml. So if your project is "TestWebAPI2", then this file should be ~/bin/TestWebAPI2.xml.

(我没看到有没有办法把这个文件移动/复制到~/App_Data,但是我找了很久没有找到)

(I couldn't see if there was a way to move/copy this file to ~/App_Data, but I didn't look for a very long time)

要使其正常工作,请转到 ~/Areas/HelpPage/App_Start/HelpPageConfig.vb 并更改以下行以适合:

To get this working, go to ~/Areas/HelpPage/App_Start/HelpPageConfig.vb and change the following line to suit:

config.SetDocumentationProvider(New XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")))

成为

config.SetDocumentationProvider(New XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/bin/<yourprojectname>.xml")))

(不要忘记将 替换为您的 WebAPI2 项目名称)

(don't forget to replace <yourprojectname> with your WebAPI2 project name)

这篇关于VS 2017 WebAPI 帮助页面 - 未提供文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆