Batch Files, madbuild.exe, and commands

Flare’s help contains topics about batch targets and there is no need to cover all of that here. Briefly, you can create batch targets for a project. From the Batch Target Editor, you can select actions to take and schedule tasks. To generate output from Flare targets using commands specified outside of the Flare user interface, you can use a command line executable called madbuild.exe. This executable is located in the Flare.app folder of your folder installation. For example:

The executable describes its usage as:

But there is also a switch to enable logging:

The primary benefit is of batch is scheduling. Scheduling builds means you don’t have to manually kick off a process, which is a time saver.

Scheduling nightly or continuous build becomes more important as the volume of content increases. For large API and database references, build times can go into hours. Waiting until the end of the day to kick off a build can be a hassle. But there are other scheduling benefits to batch processing:

  • Scheduling other tasks for post-build processing
  • Organizing build schedules for outputs with subsystems to build in parallel

Here are some other tasks you can perform:

  • If you use source control and the source control solution supports the command line, you can automate checkouts and other actions. For example, with Team Foundation Server, there is an executable called TF.exe.
  • You can perform PDF post-processing. For example, if you have a copy of Acrobat, there is an Acrobat API from Adobe which can be used to create command line utilities to run from batch.
  • Copy the output or the source to an archive. For example with XCOPY or Robocopy
  • Copy a different version of a stylesheet into the output.
  • Copy external files into the project folder structure.
  • Adjust skin CSS beyond what is possible in the Skin Editor.

Microsoft TechNet Command Line Reference

Building in parallel means firstly building subsystems at the same time and then building an encompassing output after the parallel builds. For that, you need many targets.

Check out this post about a utility (made by me) to generate batch files: Targets Everywhere. This one is good for generating a file or files for all targets in any project in a folder. You can also save configurations for the utility such as which targets are selected for inclusion. And there is an interesting post at Roughly Everything about Flare about another utility to create batch scripts: Coming soon – a new batch script builder released on CodePlex. This one looks like it is good for generating the text for commands to copy into a batch.

If you use PowerShell, most of what you do from cmd.exe is portable to PowerShell. And that is a topic for another day.

7 thoughts on “Batch Files, madbuild.exe, and commands

  1. Ibelise

    Hi Thomas,
    I’m just starting to use Flare and I find your blog very helpful. Actually I wanted to add a command line to copy a folder from my Content folder to my Output folder when building the output. I’m not a programer, so I don’t know how to do it. I figure the XCOPY command should work, but I don’t really know where to include it. I would really appreciate your help with this.
    Thanks for your help and for a great blog!

    Reply
    1. Thomas Tregner Post author

      Thanks for reading! If you want to copy a file to your output folder, place the command after the build command (madbuild.exe) in a *.bat file. Your copy won’t occur during the build. Instead, you will execute the build process outside of the Flare interface by calling madbuild.exe from a batch file. Flare’s build process clears previously built content out of a folder at the beginning of the process. There are links in the post for details about the XCOPY and Robocopy commands. The link for XCOPY should explain what the switches are for in the example below.

      XCOPY C:SourceContent C:TargetContent /s /e /i /h

      For more information about batch files, see:
      Using batch files (Microsoft TechNet, XP documentation)
      Batch file (Wikipedia)

      Reply
  2. Ibelise

    Thank you for your answer. It’s a bit complicated, though, because we are a team of writers and each writer builds their own content, so if each one has to execute the build outside of Flare it might be a problem.
    Do you know if there’s an easier way to add content folders to an output? Actually, I just wanted to embed fonts in the TOC for the Webhelp2 output. I made modifications in Style.css in the installation files ( C:Program Files (x86)MadCap SoftwareMadCap Flare V8Flare.appResourcesWebHelp2DesktopSkinsDefaultStylesheetsStyles.css) to add @font-face but since I’m having problems with the relative path in some browsers, I thought the easiest way was to include the folder in the skin style folder during the build, but maybe I’m wrong and I should look for another solution :-/

    Reply
    1. Thomas Tregner Post author

      You can include it in the same folder in Content. For example, include it in ContentResourcesStylesheets or wherever you maintain CSS. No post-build action is required to include it in the output. Just beware of the setting on the target described here:

      Excluding Content Not Linked Directly Or Indirectly From Targets

      Reply
  3. Ibelise

    Yes, that’s what I did and it works fine in all browsers but Firefox and I’m pretty sure it’s because of the relative path. That’s why I wanted the fonts folder to be at the same level as the Styles.css generated (Outputtest_webhelpSkinsDefaultStylesheets). Maybe I should just try to see what the Firefox problem is.
    Thanks again for your help.

    Reply
    1. Thomas Tregner Post author

      Are you using single or double quotes around the font name? Sometimes that is an issue with Firefox.

      Reply
  4. Ibelise

    I’m using single quotes. But I also tried with the fonts folder included manually at the same level as the stylesheet and it worked with Firefox, that’s why I assumed it was the relative path, but I should try using double quotes.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

53,013 Spambots Blocked by Simple Comments

HTML tags are not allowed.