Building and Publishing Targets Using the Command Line

Flare's build engine is called “madbuild” and is used when generating and publishing output in various ways from the command line. With this method, you do not have to open Flare at all.

Note If a destination file is associated with a target, the output will automatically be published to that destination when using a madbuild command.

Commands and Arguments

To build output from the command line, you need to write commands containing various arguments. The commands always start with the word “madbuild,” followed by the necessary arguments and values.

Here are the available arguments associated with madbuild.

-batch

Enter this before the name of the batch target you want to build.

-centralPassword

Enter this before your MadCap Central password if you are publishing a target directly to Central.

-centralUsername

Enter this before your MadCap Central user name if you are publishing a target directly to Central.

-credentials

Enter this before credentials that are added directly in the madbuild command.

Note If you do not provide credentials, those from your registry (i.e., those you entered in the Destination Editor) will automatically be used. The -credentials and -credentials-file arguments give you a way to use a different set of credentials than those in your registry.

-credentials-file

Enter this before the path to a credentials (JSON) file, which contains the actual credentials.

-export

Enter this before the path and name of the Flare project file (.flprj) you want to export. See Exporting Projects Using the Command Line.

-project

Enter this before the path and name of the Flare project file (.flprj) containing the target(s) you want to build.

-settings

Enter this before the export project file name (.flexp) when exporting a project. See Exporting Projects Using the Command Line.

-target

Enter this before the name of the Flare target you want to build.

How to Build All Targets

  1. Open Notepad (to create and save a batch file) or open your command prompt (to run a command immediately).
  2. Type the path to the Flare.app folder where you installed Flare, and press ENTER.

    cd\Program Files\MadCap Software\MadCap Flare 17\Flare.app

    Note Alternatively, you can use cd c:\Program Files\[rest of the path] instead of cd\Program Files\[rest of the path].

  1. Type the following and press ENTER on your keyboard (entering the path to your project in place of the section in angle brackets):

    madbuild -project [project]

    A log file is generated and saved automatically at the root level of the output folder for that target, whether or not there are errors or warnings. See Opening Build Logs.

    Note If there are spaces anywhere in your path or project name, you need to use quotation marks around it.

    Example If you have a Flare project called "FictionSoftPro" that you have stored in a folder of the same name at the root level of the C: drive, you can type this:

    Copy
    madbuild -project c:\fictionsoftpro\fictionsoftpro.flprj

    Example If you have a project called "FictionSoftPro" that you have stored in a folder named "My Projects" (with a space) at the root level of the C: drive, you would type this:

    Copy
    madbuild -project "c:\my projects\fictionsoftpro.flprj"

    If you are using the command prompt window, the targets in that project generate immediately, and the output files are copied to the Output subfolder in your main project folder.

    If you are creating a batch file in Notepad, it might look something like this:

How to Build a Specific Target

  1. Open Notepad (to create and save a batch file) or open your command prompt (to run a command immediately).
  2. Type the path to the Flare.app folder where you installed Flare, and press ENTER.

    cd\Program Files\MadCap Software\MadCap Flare 17\Flare.app

    Note Alternatively, you can use cd c:\Program Files\[rest of the path] instead of cd\Program Files\[rest of the path].

  1. Type the following and press ENTER on your keyboard (entering the path to your project and the name of the target in place of the sections in square brackets):

    Copy
    madbuild -project [project] -target [target name]

    A log file is generated and saved automatically at the root level of the output folder for that target, whether or not there are errors or warnings. See Opening Build Logs.

    Note The default location for targets is in the root Targets folder in the Project Organizer. However, you can create subfolders and place different targets in different folders (see Creating Subfolders). If you do this, make sure you include the subfolder name in your command. You can do this by typing the name of the subfolder, followed by a slash, and then the name of the target (i.e., madbuild -project [project] -target [mysubfoldername/mytargetname]).

    Note If there are spaces anywhere in your path or project name, you need to use quotation marks around it.

    Example You have a project called "FictionSoftPro" that you have stored in a folder of the same name at the root level of the C: drive. If you want to build only the target named "Beginner" in that project, you can type this:

    Copy
    madbuild -project c:\fictionsoftpro\fictionsoftpro.flprj -target Beginner

    Example If the project is located in a folder called "my projects" (with a space), you would type this:

    Copy
    madbuild -project "c:\my projects\fictionsoftpro.flprj" -target Beginner

    Example If the target is named "Beginner Online Help" (with spaces between words), you would type this:

    Copy
    madbuild -project "c:\my projects\fictionsoftpro.flprj" -target "Beginner Online Help"

    If you are using the command prompt window, the targets in that project generate immediately, and the output files are copied to the Output subfolder in your main project folder.

    If you are creating a batch file in Notepad, it might look something like this:

How to Build a Batch Target

  1. Open Notepad (to create and save a batch file) or open your command prompt (to run a command immediately).
  2. Type the path to the Flare.app folder where you installed Flare, and press ENTER.

    cd\Program Files\MadCap Software\MadCap Flare 17\Flare.app

    Note Alternatively, you can use cd c:\Program Files\[rest of the path] instead of cd\Program Files\[rest of the path].

  1. Type the following and press ENTER on your keyboard (entering the path to your project and the name of the target in place of the sections in angle brackets):

    Copy
    madbuild -project [project] -batch [batch target name]

    A log file is generated and saved automatically at the root level of the output folder for that target, whether or not there are errors or warnings. See Opening Build Logs.

    Note The default location for batch targets is in the root Targets folder in the Project Organizer. However, you can create subfolders and place different batch targets in different folders (see Creating Subfolders). If you do this, make sure you include the subfolder name in your command. You can do this by typing the name of the subfolder, followed by a slash, and then the name of the batch target (i.e., madbuild -project [project] -batch [mysubfoldername/mybatchtargetname]).

    Note If there are spaces anywhere in your path or project name, you need to use quotation marks around it.

    Example You have a project called "FictionsoftPro" that you have stored in a folder of the same name at the root level of the C: drive. If you want to build the batch target named "MyBatchTarget" in that project, you can type this:

    Copy
    madbuild -project c:\fictionsoftpro\fictionsoftpro.flprj -batch MyBatchTarget

    Example If the project is located in a folder called "my projects" (with a space), you would type this:

    Copy
    madbuild -project "c:\my projects\fictionsoftpro.flprj" -batch MyBatchTarget

    Example If the batch target is named "My Batch Target" (with spaces between words), you would type this:

    Copy
    madbuild -project "c:\my projects\fictionsoftpro.flprj" -batch "My Batch Target"

    If you are using the command prompt window, the targets in that project generate immediately, and the output files are copied to the Output subfolder in your main project folder.

    If you are creating a batch file in Notepad, it might look something like this:

How to Publish Directly to MadCap Central

As an alternative to building a target on MadCap Central, you can publish output directly to Central from the local Flare project. By “publish,” we mean copying your output files to Central, not making that output “live,” which would make it visible to the general public. You would still need to use Central to make that output accessible to end users. Also, you must be associated with the project on Central and have the “Run/Schedule Builds” permission. See MadCap Central and Flare.

  1. Open Notepad (to create and save a batch file) or open your command prompt (to run a command immediately).
  2. Type the path to the Flare.app folder where you installed Flare, and press ENTER.

    cd\Program Files\MadCap Software\MadCap Flare 17\Flare.app

    Note Alternatively, you can use cd c:\Program Files\[rest of the path] instead of cd\Program Files\[rest of the path].

  1. Type the following and press ENTER on your keyboard (entering the correct information in place of the sections in square brackets):

    Copy
    madbuild -project [project] -centralUsername [email address] -centralPassword [password] -target [target]

    Note If there are spaces anywhere in your path or project name, you need to use quotation marks around it.

    Example Your email address is bsmith@fictionsoft.com, and your Central password is R!ffraff22. You have a project called "FictionSoftPro" that you have stored in a folder of the same name at the root level of the C: drive. If you want to publish the target named "Beginner" to Central, you can type this:

    Copy
    madbuild -project c:\fictionsoftpro\fictionsoftpro.flprj -centralUsername bsmith@fictionsoft.com -centralPassword R!ffraff22 -target Beginner

    Example If the project is located in a folder called "my projects,” and the target is named "Beginner Online Help" (with spaces between words), you would type this:

    Copy
    madbuild -project "c:\my projects\fictionsoftpro.flprj" -centralUsername bsmith@fictionsoft.com -centralPassword R!ffraff22 -target "Beginner Online Help"

Passing Credentials in Madbuild

If you are using the command line to publish output from Flare to another location, you can include credentials (i.e., user names, passwords) in your madbuild commands. You can put credential fields directly in a madbuild command, or you can put them in a separate JSON file, which is easier to read.

Passing credentials in madbuild can be done for:

  • FTP

  • MadCap Central

  • Salesforce®

  • ServiceNow®

  • SFTP

  • Zendesk

Note If a destination file is associated with a target, the output will automatically be published to that destination when using a madbuild command.

Credential Fields

Here are the supported credential fields.

username

The user name for basic authentication.

password

The password for basic authentication.

Note For Salesforce®, the password is that you use in a command is actually the password plus the token appended at the end of it. You can generate the token in Salesforce® from My Settings > Personal > Reset My Security Token.

Note For Zendesk, "Password Access" needs to be enabled from API settings in Zendesk in order for it to work.

Also, with Zendesk you have the option of using a token only, as opposed to using the username and password. For more details on this, see the following:

https://support.zendesk.com/hc/en-us/articles/203663836-Using-OAuth-authentication-with-your-application

Credential URL Formats

Here are the formats for including credential fields, depending on the type of destination.

FTP and SFTP

Copy
https://[hosturl]/[directory]

Note This is the same as what you enter in the Host Name and Directory fields in the Destination Editor.

MadCap Central

Copy
https://portal.madcapcentral.com/

Salesforce®

If your are publishing to a regular Salesforce® instance:

Copy
https://login.salesforce.com/services/oauth2/authorize

If you are publishing to a sandbox Salesforce® instance:

Copy
https://test.salesforce.com/services/oauth2/authorize

ServiceNow®

Copy
https://[instance].service-now.com/oauth_token.do

Zendesk

Copy
https://[subdomain].zendesk.com/oauth/authorizations/new

Passing Credentials in Madbuild Command

In this case, you put the credentials directly into your madbuild command.

Copy
madbuild -project "C:\MyProjectFolder\MyProject.flprj" -target "MyTargetName" 
-credentials  "{\"https://url.com/dir\": {\"username\":\"myusername\", \"password\": 
\"mypassword\"}, \"https://anotherurl.com/dir\": {\"username\":\"myusername\"
\"password\":\"mypassword\"} }"

Example – FTP

Copy
madbuild -project "C:\CoolProject\CoolProject.flprj" -target "HelpSystem" 
-credentials  "{\"https://docs.fictionsoft.com/flareoutputs/helpsystem\": 
{\"username\":\"ldobler\", \"password\": \"sayanything\"} }"

Example – MadCap Central

Copy
madbuild -project "C:\CoolProject\CoolProject.flprj" -target "HelpSystem" 
-credentials  "{\"https://portal.madcapcentral.com/\": 
{\"username\":\"breynolds@fictionsoft.com\", \"password\": \"Bandit77!\"} }"

Example – Salesforce®

Copy
madbuild -project "C:\CoolProject\CoolProject.flprj" -target "HelpSystem" 
-credentials  "{\"https://login.salesforce.com/services/oauth2/authorize\": 
{\"username\":\"pete@fictionsoft.com\", \"password\"
\"HeDoneRunnoft!Fj4bGioaIWS9OPakVCedIjk2\"} }"

Example – ServiceNow®

Copy
madbuild -project "C:\CoolProject\CoolProject.flprj" -target "HelpSystem" 
-credentials  "{\"https://docs52164.service-now.com/oauth_token.do\": 
{\"username\":\"steve.zissou\", \"password\": \"CompanyBondStooge!\"} }"

Example – SFTP

Copy
madbuild -project "C:\CoolProject\CoolProject.flprj" -target "HelpSystem" 
-credentials  "{\"https://myappserver05:0101/flareoutputs/helpsystem\": 
{\"username\":\"jlebowski\", \"password\": \"thedudeabides\"} }"

Example – Zendesk

Copy
madbuild -project "C:\CoolProject\CoolProject.flprj" -target "HelpSystem" 
-credentials  "{\"https://docs-fictionsoft.zendesk.com/oauth/authorizations/new\": 
{\"username\":\"westley@fictionsoft.com\", \"password\": \"AsYouWish!\"} }"

Example – Multiple Destinations (FTP and Salesforce®)

Copy
madbuild -project "C:\CoolProject\CoolProject.flprj" -target "HelpSystem" 
-credentials  "{\"https://docs.fictionsoft.com/flareoutputs/helpsystem\": 
{\"username\":\"ldobler\", \"password\": \"sayanything\"}, 
\"https://login.salesforce.com/services/oauth2/authorize\"
{\"username\":\"pete@fictionsoft.com\", \"password\"
\"HeDoneRunnoft!Fj4bGioaIWS9OPakVCedIjk2\"} }"

Passing Credentials in a JSON File

In this case, you put the credentials into a JSON file. Then, in your madbuild command, you point to that file.

One of the benefits of placing commands in a JSON file is that it is easier to include (and read) multiple sets of URLs and credential information in one place if you have that need.

JSON File

Copy
{
    "https://url.com/dir" : {
     "username": "myusername",
     "password": "mypassword"
    },
    
    "https://anotherurl/dir": {
     "username": "myusername",
     "password": "mypassword"
    }
}

Madbuild Command

Copy
madbuild -project "C:\MyProjectFolder\MyProject.flprj" -target "MyTargetName" 
-credentials-file "C:\MyCredentialsFolder\MyCredentialsFile.json"

Example — Multiple Destinations

You create a file named "DestinationCredentials.json" and save it in a folder called "My-JSON-Files," at your root C: drive. In the DestinationCredentials.json file, you create commands for the different kinds of destinations (FTP, Salesforce®, ServiceNow®, SFTP, Zendesk) that can be associated with one or more projects and targets. The JSON file looks like this.

Copy
{
  "https://docs.fictionsoft.com/flareoutputs/helpsystem" : {
  "username": "ldober",
  "password": "sayanything"
 },
 
 "https://portal.madcapcentral.com/" : {
 "username": "breynolds@fictionsoft.com",
 "password": "Bandit77!"
 },
  
  "https://login.salesforce.com/services/oauth2/authorize" : {
  "username": "pete@fictionsoft.com",
  "password": "HeDoneRunnoft!Fj4bGioaIWS9OPakVCedIjk2"
 },
  
  "https://docs52164.service-now.com/oauth_token.do" : {
  "username": "steve.zissou",
  "password": "CompanyBondStooge!"
 },
 
  "https://myappserver05:0101/flareoutputs/helpsystem" : {
  "username": "jlebowski",
  "password": "thedudeabides"
 },
 
  "https://docs-fictionsoft.zendesk.com/oauth/authorizations/new" : {
  "username": "westley@fictionsoft.com",
  "password": "AsYouWish!"
 }
}

Then, you create a madbuild command like this:

Copy
madbuild -project "C:\CoolProject\CoolProject.flprj" -target "HelpSystem" 
-credentials-file "C:\My-JSON-Files\DestinationCredentials.json"

When you run this command the output is generated for the "HelpSystem" target, and the output files are copied and placed in each of the locations specified in the JSON file.

Batch Files and Task Scheduler

If you are creating a batch file, save the Notepad file to any location you like on your computer. When you do this, type .bat as the extension at the end of the file name (e.g., MyBatchFile.bat). At any time you like, you can generate the output simply by double-clicking the batch file. You can also use a tool to schedule the batch file to run.

For example, complete the following steps if using the Windows 10 Task Scheduler utility.

  1. In the Windows search field, type Task Scheduler and press ENTER.
  2. Click Action > Create Basic Task.
  3. In the Create Basic Task Wizard, give the task a name and click Next.
  4. Using the next couple of pages of the wizard, choose when you wan the batch to run (e.g., daily, starting at 2 a.m.). Click Next until you get to the Action page.
  5. Click Start a program, and click Next.
  6. Click Browse. Then find and double-click the batch file you created.
  7. Click Next.
  8. Click Finish.

ERRORLEVEL Global Variable

If you generate output using the command line, Flare sends a value to the command line's ERRORLEVEL global variable. This value indicates the success, or lack of success, of the compilation and/or publishing process. To see this value, type ECHO %ERRORLEVEL% at the command prompt after the compilation finishes. Only one value can be shown at a time.

Important For more details on a particular error code, please refer to the log file that is generated. See Opening Build Logs.

Codes listed below in red indicate that the output did not compile at all. For the other codes, there may be issues (e.g., missing linked file), but the output is still able to finish compiling.

Common Codes

  • 0 = Success - No problems
  • 1 = One or more Target Builds failed – One or more of the targets failed to compile

  • 2 = One or more Publish Targets failed – One or more of the targets failed to compile

  • 3 = Build completed with compiler warnings
  • 4 = Compiler reported errors
  • 5 = Failed to process one or more project import files
  • 6 = Failed to load topic
  • 7 = Missing linked file

Other Codes

  • -1 = Application error – Something critical has forced Flare to close

  • 1000 = Zero arguments passed in

  • 1001 = Show Help
  • 2000 = Unlicensed Flare

  • 2001 = Flare not activated

  • 2002 = Invalid license activation code

  • 2003 = License expired

  • 2004 = Evaluation expired

  • 2005 = Trial expired

  • 2006 = Project does not exist

  • 2007 = Batch file does not exist

  • 2008 = Floating session request failed

  • 2009 = Floating session timeout

  • 2010 = Target not found

What’s Noteworthy?

Warning If your computer's anti-virus (AV) software scans the Output folder during the build process and you experience one or more "Build Failed" errors, the AV software may be preventing the build process from accessing the output files. To avoid this, you can temporarily turn off or disable your AV scan. You may also be able to exclude the Output folder, add Flare to an exceptions list, or postpone/reschedule scans to a different time. See your AV vendor for information.

Tip If you are using the command prompt (as opposed to a Notepad file) and you have an operating system that supports dragging, you can drag a file from the Windows location to the Command Prompt window. This will add the path of the file within quotation marks for you.

What’s Next?

After you build targets using the command line, you can do the following: