Tag Archives: batch

Automating Imports

If you work with more than a few projects that import from a common project, you may want to automate importing from that project. Automating imports can be as simple as scheduling this command:

 How does that work? Isn’t madbuild.exe for generating output content?

Yes. But some other things happen when a target is built.

Flare targets have an Auto-Sync feature that enables running an import prior to generating content. Auto-Sync can be disabled for a target from the Target Editor. The setting is on the General tab, under Auto-Sync: Disable auto-sync of all import files. When not checked, the option is specified in the target file markup as a DisableAutoSync=”false” attribute and value on the CatapultTarget element. The value is true when the box is checked.

Flare imports have a setting on the Source Project tab called Auto-reimport before “Generate Output”.  Targets with Auto-Sync enabled will prompt an import specified by the import files with the Auto-reimport before “Generate Output” option selected. The markup for this option is AutoSync=”true” on the CatapultProjectImport element.

The command line executable that enables starting builds outside of the Flare user interface is called madbuild.exe. It is located in the folder where Flare is installed. When a target is built with madbuild.exe, Auto-Sync is still run if specified. However if the project is under source control, madbuild.exe does not prompt for a checkout as happens in the Flare interface. But more about that later.

By the way, this post is a follow-up to a previous discussion about batch files called Batch Files, madbuild.exe, and commands.

Setting up automated imports is accomplished by scheduling builds of targets that cause an import with Auto-Sync. Builds can be scheduled by placing build commands in a batch file and scheduling a call to the batch file with Windows Scheduler.

The target can be a throw-away that builds a one topic TOC. The output doesn’t matter. The target is just a means to get madbuild.exe to cause an import.

But I use source control and madbuild.exe does not prompt me to check files in or out.

Depending on your source control solution, you can automate that also. For example with Team Foundation Server and Visual Studio (Team Explorer), the executable is tf.exe and it is located in a Visual Studio folder.

One thing to watch out for is that not every file in a project should be checked in and out of source control. Some folders are local such as the Output folder in the root of the project and Users folders in the Project folder. The second example that follows shows this.

Build Commands

 

Build with TFS Source Control Commands

 

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.