8

I am using the Sandcastle Help File Builder to output my C# XML-DOC file to the Website format. How can I accomplish the samething from the command line so that I can add this as a build event in Visual Studio when building the actual project?

The end goal is to have the website Help File content built when I build the Visual Studio project.

John Chapman
  • 878
  • 3
  • 14
  • 28

4 Answers4

9

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.

Michael Sorens
  • 35,361
  • 26
  • 116
  • 172
  • 1
    So, as mentioned on a comment on another answer, as a Post-Build event on the normal Visual Studio build properties, I added the command to build the SHFBPROJ file with MSBuild (similar to what you posted on the first code snippet). However, when running the build, it started over 1000 instances of MSBuild.exe in task manager and locked up. Any ideas why? – John Chapman Oct 25 '11 at 19:14
  • BTW, the build when I use the Help Builder to compile it instead of MSBuild, it takes about 2 minutes. Adding it to the post build ran for over an hour at 100% CPU utilization until I finally just killed it. – John Chapman Oct 25 '11 at 19:15
  • @JohnChapman: What is that "Help Builder" you are referring to? Is it something included in the SHFB package? – O. R. Mapper Oct 28 '17 at 21:40
1

You could call SandCastle from the post build event command line, in the Build Events section of your project properties. This should work nicely if you are not using any automated build tool.

Scott Wylie
  • 4,725
  • 2
  • 36
  • 48
  • technically if you edit your build events in the properties window you are using the MSBuild automated build tool. Just wanted to clarify. – ajrawson Oct 24 '11 at 22:59
  • How would I do this specifically? I found a way to call MSBuild against the Sandcastle project file, however it starts over 1000 separate MSBuild processes and locks up the computer (doesn't do that when building from the GUI). – John Chapman Oct 25 '11 at 17:39
0

I found it easiest to just add the *.shfbproj project to the solution. It builds fine (although a bit slowly) inside of VS 2010.

Robert Bratton
  • 435
  • 1
  • 5
  • 12
  • I can't add the shfbproj file in VS2013. (I do not have the SHFB extension installed as that may pollute the solution build target.) – user2864740 Mar 02 '15 at 17:30
0

If you're using MSBuild for your build tool this is the tutorial I used awhile back.

There is also a script on codeplex that you can look into using that might help you out.

Hope this helps!

ajrawson
  • 1,724
  • 1
  • 14
  • 20