Build SHFB from source code - problems with reflection data.

Topics: Developer Forum, User Forum
Apr 9, 2014 at 3:55 AM
Hi Eric (or anyone else who could help), I am trying to build the source code projects in order to fix my reported bug https://shfb.codeplex.com/workitem/35108

In theory it should be simply encoding before writing this
 sw.WriteLine("<topic id=\"{0}\" file=\"{0}\" sortOrder=\"{1}\">",
                    rootContainerId, rootOrder);
in SaveToIntermediateTocFile


Anyway, I downloaded the code, explored the projects, built them from VS, which meant using nuGet to download something (unsure what it did actually) and then couple of the solutions built OK in VS.,

Then I tried to do this bit from the readme

_Before using the source code version, you will need to build the tools and the reflection data files. To do
this, open a command prompt, change into the root folder and run the MasterBuild.bat script. This will build
the tools and place them in the SHFB\Deploy folder ready for use. Once that completes, change into the
SHFB\Deploy\Data folder and execute the BuildReflectionData.bat script. This will generate the reflection data
files for the .NET Framework into a temporary folder. Rename the folder it creates to "Reflection"._



But it gives lots of these errors when I do MasterBuild.bat
C:\...Sandcastle-105454\SHFB\Source\Setup\Deployme
ntFiles.wxs(1657): error LGHT0103: The system cannot find the file '..\..\Deplo
y\\Data\Reflection\System.Xml.Xsl.Runtime.xml'. [C:\...\Sandcastle-105454\SHFB\Source\Setup\Setup.wixproj]
which seems to indicate that the BuildReflectionData.bat script needs to be run first since it generates the 'reflection' folder, right? But that gives me
C:\...\Sandcastle-105454\SHFB\Deploy\Data>BuildReflectionData.bat 4.0 4.0
*
* Building .NET Framework reflection data files using tools in C:\...\Sandcastle-105454\SHFB\Deploy\Data\..\
*
Microsoft (R) Build Engine version 4.0.30319.18408
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 08/04/2014 8:40:21 PM.
Project "C:\...\Sandcastle-105454\SHFB\Deploy\Data\
BuildReflectionData.proj" on node 1 (default targets).
Reflection:
  Directory ".\Tmp" doesn't exist. Skipping.
  Directory ".\4.0_4.0" doesn't exist. Skipping.
  Creating directory ".\Tmp".
  Creating directory ".\4.0_4.0".
  "C:\...\Sandcastle-105454\SHFB\Deploy\Data\..\\MR
  efBuilder.exe" @MRefBuilder.rsp /out:".\Tmp\Reflection.org"
  MRefBuilder (v2014.1.26.0)
  Copyright © 2006-2014, Microsoft Corporation, All Rights Reserved.
  Portions Copyright © 2006-2014, Eric Woodruff, All Rights Reserved.
  Specify at least one assembly to reflect.
  The command ""C:\...\Sandcastle-105454\SHFB\Deplo
  y\Data\..\\MRefBuilder.exe" @MRefBuilder.rsp /out:".\Tmp\Reflection.org"" exi
  ted with code 1.
C:\...\Sandcastle-105454\SHFB\Deploy\Data\BuildRefl
ectionData.proj(35,5): error MSB3030: Could not copy the file ".\Tmp\Reflection
.org" because it was not found.
Done Building Project "C:\...\Sandcastle-105454\SHF
B\Deploy\Data\BuildReflectionData.proj" (default targets) -- FAILED.


    Build FAILED.

"C:\...\Sandcastle-105454\SHFB\Deploy\Data\BuildRef
lectionData.proj" (default target) (1) ->
(Reflection target) ->
  C:\...\Sandcastle-105454\SHFB\Deploy\Data\BuildRe
flectionData.proj(35,5): error MSB3030: Could not copy the file ".\Tmp\Reflecti
on.org" because it was not found.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.28
*
* Build failed!
*

Note, I did use the cmd BuildReflectionData.bat 4.0 4.0, because I don't have .NET 4.5.1 and the command failed otherwise with
  EXEC : error : An error occurred while loading assemblies for reflection. The
 error message is: Could not find a part of the path 'C:\Program Files (x86)\Re
ference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1'. [C:\...\Sandcastle-   105454\SHFB\Deploy\Data\BuildReflectionData.proj]

So, should I get 4.5.1, or am I calling the buildreflectiondata incorrectly?

Thanks!
Coordinator
Apr 9, 2014 at 3:26 PM
Edited Apr 9, 2014 at 3:59 PM
You can install .NET 4.5.1 which is what it looks for by default or, if you've just got .NET 4.0, you can pass in the parameters to tell it what to build:
BuildReflectionData .NETFramework 4.0.30319
Regarding the fix for your issue, you'll also want to update SandcastleBuilderUtils\ConceptualContent\TocEntry.cs by replacing the lines in the case statement starting at line 649 with this:
case HelpFileFormats.MSHelpViewer:
    if(String.IsNullOrEmpty(this.DestinationFile))
    {
        url = HttpUtility.HtmlEncode(this.Id);
        titleAttr = String.Format(CultureInfo.InvariantCulture, " title=\"{0}\"",
            HttpUtility.HtmlEncode(this.Title));
    }
    else
    {
        url = HttpUtility.HtmlEncode(Path.GetFileNameWithoutExtension(this.DestinationFile));
        titleAttr = String.Empty;
    }
Eric
Marked as answer by shipwreckman on 4/9/2014 at 11:40 AM
Apr 9, 2014 at 6:39 PM
Thanks for the tip, that helped (although not quite).

Firstly for anyone else, I tried BuildReflectionData .NETFramework 4.0 but it didn't work, whereas BuildReflectionData .NETFramework 4.5 did (I have 4.5.0 but not 4.5.1).


There was another place to change for me;

SandcastleHtmlExtract.cs

WriteWebsiteTableOfContents

has (line 985)
   title = HttpUtility.HtmlEncode(title);
and it needs
                            title = HttpUtility.HtmlEncode(title);
                            htmlFile = HttpUtility.HtmlEncode(htmlFile);