Setting Sandcastle_DocumentationSetName at build time

Topics: DocSites, Extensibility, Sandcastle
Jun 1, 2009 at 11:45 AM
Edited Jun 1, 2009 at 11:45 AM

Hi,

 I am looking for a way to set/override the Sandcastle_DocumentationSetName property in the project file at runtime. The idea is that I want to set it to the following:

Dim newName As String = String.Format("{0} {1}.{2}", My.Application.Info.ProductName, My.Application.Info.Version.Major, My.Application.Info.Version.MajorRevision)

I am trying to do this via the BuildProcess.BuildStarting method, and I require to to work both in Team Build and local. I may be missing something but I can't find, Even using reflector, where this property resides...

 

Jun 10, 2009 at 5:10 PM
Edited Jun 10, 2009 at 6:36 PM

Hi,

The DocumentationSetName propery is located in the SandcastleProjectOptions class: http://docproject.codeplex.com/SourceControl/changeset/view/34004#454543

You can set a custom value as follows.  (I'm more fluent in C#, but if you need help translating to VB please ask.)

public override void BuildStarting(BuildContext context)

{

  // Uncomment the following line to break into the debugger:

  // System.Diagnostics.Debugger.Break();

 

  buildStart = DateTime.Now;

 

  SandcastleBuildEngine engine = (SandcastleBuildEngine) context.Engine;

  SandcastleProjectOptions options = engine.Options;

 

  System.Reflection.AssemblyName name = context.Sources[0].Input.AssemblyName;

 

  var assembly = System.Reflection.Assembly.Load(name);

 

  var product = (System.Reflection.AssemblyProductAttribute)

    assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyProductAttribute), true)[0];

 

  options.DocumentationSetName = product.Product + " " + name.Version.ToString();

}

You must add an assembly reference to DaveSexton.DocProject.Sandcastle.dll, typically found at, C:\Program Files\Dave Sexton\DocProject\bin\.  Also add a using/import declaration for DaveSexton.DocProject.Sandcastle.

Note that there is a bug in how DocumentationSetName property is used by DocProject 1.11.0 in that it will prevent you from using periods (.) in the value - they will be replaced with underscores (_) automatically.

Alternatively, you can open your project's Help\Settings\Projects\help1x.config file, set <line>Title=Your Custom Title</line> and then rebuild the project.  This can of course be done programmatically as well in the BuildStarting method, and you can use any values you want in the title, including periods.

- Dave