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

SHFBROOT and error:task could not be loaded from the assembly \SandcastleBuilder.Utils.dll

Topics: Developer Forum, Project Management Forum, User Forum
Jul 30, 2009 at 9:23 PM

I am trying to generate Sandcastle documentation as part of the build process. The build machine doesn't have Sandcastle installed on it but has Public directories for Sandcastle File Help Builder.

In my project .shfbproj file I point to the SandcastleHelpFileBuilder.targets as below (and this seems to work):

<font size="2" color="#0000ff"><font size="2" color="#0000ff">


</font></font><font size="2" color="#0000ff">



Import Project="$(PublicRoot)\...\SandcastleHFB\\SandcastleHelpFileBuilder.targets" />


Documentation is generated if I manually set environment variable as "set SHFBROOT=c:\...\Public\SandcastleHFB\\" on the command line and then build.

Instead if in the shfbproj file I have the SHFBROOT set relative to the project directory


<font size="2" color="#0000ff"><font size="2" color="#0000ff">


</font></font><font size="2" color="#0000ff">






I get the following error :



error MSB4062: The "SandcastleBuilder.Utils.MSBuild.BuildHelp" task coul
d not be loaded from the assembly $publicRoot\......\...\\SandcastleBuilder.Utils.dll. Could not
 load file or assembly 'file:///$publicRoot\......\...\\1.8.0
.2\SandcastleBuilder.Utils.dll' or one of its dependencies. The system cannot f
ind the file specified. Confirm that the <UsingTask> declaration is correct, an
d that the assembly and all its dependencies are available.

The evaluation of SHFBROOT is incorrect but I don't know how to fix this.

Is there anyway to get around this problem by setting the environment variable in the shfbproj file (which i don't know how to do :() or any other way so the build machine doesn't have to install Sandcastle

Jul 31, 2009 at 5:55 PM
Edited Jul 31, 2009 at 5:57 PM

Don't mess with the targets file or the project file manually.  All you need to do is define a system environment variable on the server called SHFBROOT that points to the location of the SHFB executables.  The same goes for Sandcastle itself.  You can put it wherever you like as long as you define a system environment variable called DXROOT that points to its root folder.  One other possible alternative is to pass those variables to MSBuild on the command line using the /p option.



Aug 6, 2011 at 1:02 PM
Edited Aug 6, 2011 at 1:02 PM


I am having a similar problem. Everything was working fine with the script that I have to build documentation via the command line:

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" "MyAPI.shfbproj" 

I want to run this on machines that have the Sandcastle files but where the install was not run, so I added a call to setx for SHFBROOT. On my test machine I deleted this environment variable and ran the script with setx and the call to MSBuild.

SHFBROOT has the same value that it had before I ran the script, but now the help wont build and I can't even create a new project in Sandcastle GUI

The error when I build is

Generating reflection information...[C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe]C:\MyProgram\Dev\MyProgramAdditions\API_Documentation\Build\Help\Working\GenerateRefInfo.proj(58,5): error MSB4062: The &quot;SandcastleBuilder.Utils.MSBuild.MRefBuilder&quot; task could not be loaded from the assembly C:\MyProgram\Dev\MyProgramAdditions\API_Documentation\Build\Help\Working\ C:\MyProgram\Dev\ThirdParty\MyProgramAPI\Documentation\Sandcastle Help File Builder\\SandcastleBuilder.Utils.dll. Could not load file or assembly &#39;file:///C:\MyProgram\Dev\MyProgramAdditions\API_Documentation\Build\Help\Working\ C:\MyProgram\Dev\ThirdParty\MyProgramAPI\Documentation\Sandcastle Help File Builder\SandcastleBuilder.Utils.dll&#39; or one of its dependencies. The filename, directory name, or volume label syntax is incorrect. Confirm that the &lt;UsingTask&gt; declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

The Using task in the proj file is

  <UsingTask TaskName="SandcastleBuilder.Utils.MSBuild.MRefBuilder" AssemblyFile="$(SHFBROOT)\SandcastleBuilder.Utils.dll" />

If I launch the Sandcastle GUI, click the New button, and enter a name, the error is 

The imported project "C:\MyProgram\Dev\MyProgramAdditions\API_Documentation\Build\
C:\MyProgram\Dev\ThirdParty\MyProgramAPI\Documentation\Sandcastle Help File Builder\SandcastleHelpFileBuilder.targets" was not found.
Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

So it feels like somehow I have messed up the entire computer's relationship with Sandcastle, though all that I think I did was delete and recreate the SHFBROOT variable with the same value it had previously.

Any help would be much appreciated.



Aug 6, 2011 at 9:14 PM

From the look of it, it's looking in the project directory in all cases for the build assemblies.  As such, I'd say that your SHFBROOT environment variable is not set.  Add it as a system environment variable and, if necessary, reboot so that it takes effect.