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:

C:\Program Files (x86)\MadCap Software\MadCap Flare V8\Flare.app

The executable describes its usage as:

madbuild -project <project file> [ -target <target name> ]
If no target specified, compiles all targets.

But there is also a switch to enable logging:

-log true

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.

10 comments

  1. 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!

    1. 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)

  2. 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 :-/

    1. 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

  3. 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.

  4. 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.

  5. I am trying to use embedded fonts so that my help matches the product. I have succeeded with the Help but not the navigation (TOC). How do I use embedded fonts in the Skin?

    I have added a fonts folder under ResourcesStylesheets. My project CSS files have the @fontface section and that is working properly, but the Skin does not seem to use my project CSS at all.

    Any thoughts?

    Thanks for your help. Ana

    1. Hi!

      I just came across this blog and your post. I’m trying to do the exact thing you asked about in this post and am wondering if you figured out the answer to your question? If so, would you please share what you found out with me? I would be extremely grateful for any and all help trying to figure out this question.

      Thank you,
      Danielle

  6. Hi Thomas,
    Great article. Thank you!
    Recently my colleague was doing a build within the Flare UI but the build kept failing and no logs were produced. I decided to use Madbuild.exe and output messages to a text file. I started the build and noticed that Madbuild ignored all conditions that were applied to the target. Then Madbuild automatically did the publish. I looked at the site where content was published and it was a mess. My colleague got her build/publish to work so the problem was fixed.

    Have you heard of Madbuild ignoring conditions?

    Thanks,
    Steve

Leave a comment

Your email address will not be published.

HTML tags are not allowed.

250,717 Spambots Blocked by Simple Comments