This project has moved and is read-only. For the latest updates, please go here.

Run portable version of Sandcastle in VS post-build step?

Topics: Developer Forum, User Forum
Mar 17, 2014 at 4:44 PM
My VS post-build step successfully generates documentation when it's defined like this:
<PropertyGroup Condition=" '$(Configuration)' == 'API Docs' ">
    <PostBuildEvent>%25SystemRoot%25\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration="API Docs" $(ProjectDir)MyProject.shfbproj</PostBuildEvent>
However, this requires SHFB to be installed on build and developer machines. I'd like to instead place an SHFB install footprint in a known location (checked into source control, so every dev has the same version) and have the post-build step run that. However, modifying the pos-build step to this instead causes the SHFB UI to popup.
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <PropertyGroup Condition=" '$(Configuration)' == 'API Docs' ">
    <PostBuildEvent>$(ProjectDir)..\..\Tools\Sandcastle\SHFBProjectLauncher.exe $(ProjectDir)MyProject.shfbproj</PostBuildEvent>
Is it invoke a "portable" version of Sandcastle in a post-build step?
Mar 17, 2014 at 8:15 PM
This is possible with the latest release. In your post build event, you might be able to set the SHFBROOT environment variable like this prior to calling MSBuild:
SET SHFBROOT=$(ProjectDir)..\..\Tools\Sandcastle
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration="API Docs" $(ProjectDir)MyProject.shfbproj
If that doesn't work, add a property to your SHFB project file that defines the SHFBROOT value conditionally. See XCOPY/Build Server Deployment topic for more information and an example.

Marked as answer by ravib on 3/17/2014 at 2:12 PM
Mar 17, 2014 at 9:52 PM
Edited Mar 17, 2014 at 9:53 PM
I added the following property to MyProject.shfbproj. The property was added unconditionally since MyProject's post-build step is already set to be conditional on the configuration "API Docs".
When I rebuild my project (using the "API Docs" configuration), I now get the following error:
Reflection data files do not exist yet [D:\MyApp\SomeFolder\MyProject\MyProject.shfbproj]
I've confirmed that the ..\..\Tools\Sandcastle folder does in fact contain the ./Data/Reflection folder which is populated with 460 .xml files.

A nudge in the right direction would be appreciated


Mar 17, 2014 at 10:12 PM
Never mind, Eric. Your suggestion to set the SHFBROOT environment variable in the post-build step was spot on. Thank you!

Mar 17, 2014 at 10:13 PM
Check the build log. Where does it say the Sandcastle tools are located? The Data\Reflection folder should be under it. You didn't say which release you are using. It has to be 2014.1.26.0 or later. Version and earlier probably won't work.

Mar 17, 2014 at 10:21 PM
I'm using version 2014.2.15.0 Beta.