127

四种Sandcastle方法生成c#.net帮助类帮助文档 - 安于生

 6 years ago
source link: http://www.cnblogs.com/anyushengcms/p/7682501.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

     方法一、Visual Studio新建documentation生成帮助文档

        前段时间在网上收集和自己平时工作总结整理了《干货,比较全面的c#.net公共帮助类》,整理完成上传github之后我又想,既然是帮助类,总得有个帮助文档于是乎想到了Sandcastle,Sandcastle是微软官方生成帮助文档这发面的工具。

       它可以配合Microsoft Visual Studio生成的dll和xml注释文件生成完整的帮助文档。

       结合可视化工具Sandcastle Help File Builder,简单直接,还能生成各种属性的说明。

       支持Helpe1x:chm, Helper2x:Hxs, Website,HelperView等多种格式而且扩展灵活功能强大,下面我们就看一下怎样用Sandcastle生成chm文档。

     首先我们前往CodePlex下载Sandcastle,地址:http://sandcastle.codeplex.com/

     然后下载Sandcastle Help File Builder,地址:http://shfb.codeplex.com/,点击右边download下载即可。

      Sandcastle,直接Next就可以了,Sandcastle Help File Builder要说一下的是,在MAML Schema IntelliSense for Visual Studio为vs安装插件的时候一定要勾选上,不然新建项目的时候会没有这个选项。

1202772-20171017154816615-990994064.png
1202772-20171017154828974-1427891205.png
1202772-20171017154853474-1093270629.png
1202772-20171017155655756-1879307506.png

    在生成这里设置xml文档文件,保存,编译之后在你项目目录的bin\Debug就会看到生成的xml文件了。

四、新建项目documentation

1202772-20171017160012240-152749447.png

    首先 新建documentation项目,这里就是安装Sandcastle Help File Builder的时候勾选上vs的原因。如果没有勾选上,这里新建的时候没有这个选项的。

1202772-20171017160433115-1184268967.png

    

1202772-20171017160635740-393505479.png

 然后勾选上你刚才已经生成的dll和xml文件,右键属性如上图写上标题。编译生成即可。这里有一点要注意,可能会报错(SHFB: Error BE0037: Could not find the path the the HTML Help 1 compiler. See the error number topic in the help file for details.),是没有安装Microsoft HTML Help,当然你安装了之后可以跳过此步骤。

1202772-20171017161106162-1595155178.png

如果没有安装Microsoft HTML Help,我们到https://www.microsoft.com/en-us/download/details.aspx?id=21138去下载Microsoft HTML Help然后安装。

如果没有报错,直接生成,然后我们项目目录的Help就可以看到生成的帮助文档了

1202772-20171017161452599-676755614.png

     是不是很简单。这样我们就生成了之前帮助类的帮助文档了。另外我再介绍几种生成帮助文档的方式。

方法二、cmd生成帮助文档

在Sandcastle和Sandcastle Help File Builder都安装好的前提下,

在我们将步骤三生成的Common.Utility.dll 和Common.Utility.xml 拷贝至C:\Program Files (x86)\Sandcastle\Examples\Sandcastle(Sandcastle安装路径)下面。

这种方法是一种批处理的方法,然后我们打开cmd,输入build_sandcastle.bat vs2005 Common.Utility 回车,然后进行批处理。

我们会看到这目录下生成很多文件夹,如果过程没有报错,我们在chm 文件夹就会看到我们生成的帮助文档了。

方法三、SandcastleBuilderGUI

1202772-20171017162829084-1217967527.png
1202772-20171017162920662-1256306858.png

我们根据上面的设置,然后引入Common.Utility.dll 和Common.Utility.xml,生成即可。相关设置参考:http://www.cnblogs.com/lonely7345/archive/2010/01/13/1647245.html

方法四、Sandcastle Help File Builder可视化工具

通过Sandcastle的图形操作界面。在C:\Program Files (x86)\Sandcastle\Examples\Generic\SandcastleGui.exe下打开如下界面。

1202772-20171017163302865-1007209972.png

根据图上相关设置然后点击Build按钮。即可生成帮助文档,是不是更方便简洁。

当然前提是也是生成Common.Utility.dll 和Common.Utility.xml的情况下面。

如上四种方法生成帮助文档。至此c#.net帮助类告一段落。

github地址:https://github.com/Jimmey-Jiang/Common.Utility喜欢点下star


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK