我正在使用 Sandcastle 帮助文件生成器将我的 C# XML-DOC 文件输出为网站格式。如何从命令行完成相同的操作,以便在构建实际项目时将其添加为 Visual Studio 中的构建事件?
最终目标是在我构建 Visual Studio 项目时构建网站帮助文件内容。
我正在使用 Sandcastle 帮助文件生成器将我的 C# XML-DOC 文件输出为网站格式。如何从命令行完成相同的操作,以便在构建实际项目时将其添加为 Visual Studio 中的构建事件?
最终目标是在我构建 Visual Studio 项目时构建网站帮助文件内容。
As Scott Wylie indicated, you need to specify this in the post build event command line in Visual Studio's project properties. However, I would suggest using Sandcastle Help File Builder (SHFB) rather than Sandcastle directly. It makes the command line call short and simple as shown below, but note that first you have to configure the SHFB project with the SHFB GUI, which creates an msbuild-compatible build file with the ".shfbproj" suffix:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release myProject.shfbproj
However, note that I take the opposite approach from what you are doing: instead of using Visual Studio to interactively launch a build and ancillary actions, I use ant (nant) to launch a build of everything, which includes my Visual Studio solutions and subsequent SHFB action. So this is really the command-line call I make to build the documentation with Sandcastle:
<exec executable="${msbuild}" dir="${csharpdoc}" output="${csharpdoc.log}">
<arg value="/p:Configuration=Release"/>
<arg value="myProject.shfbproj"/>
</exec>
My preference is that the entire build should be launchable from the command line so there are no interactions required (e.g. launching Visual Studio, etc.). That provides the flexibility to run either as a scheduled recurring task or on-demand from the shell.
您可以在项目属性的 Build Events 部分中从构建后事件命令行调用 SandCastle。如果您不使用任何自动构建工具,这应该可以很好地工作。
我发现将 *.shfbproj 项目添加到解决方案中最简单。它在 VS 2010 内部构建良好(虽然有点慢)。