Command Line Build batch file

This forum is for all Flare related Tips and Tricks.
Have a tip or trick you use while working in Flare? Share it here.
SteveS
Senior Propellus Maximus
Posts: 2087
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: Command Line Build batch file

Post by SteveS »

Code: Select all

madbuild -project  %1 >> c:\\temp\\madbuild.txt
An explanantion!

The %1 is used as a placeholder for parameters, in this case the projects. It will run the batch file on the first parameter and then shift to the next and so on until all the parameters have been used. You can replace the %1 with your project path if you wish. I used it because I had the batch file on my desktop and would drag and drop a Flare project from Windows explorer onto the batch file to make it run.

>> c:\\temp\\madbuild.txt is a redirection. Rather than sending messages to the CLI window it sends them to a file in C\temp called madbuild.txt - and there is a bug in the batch file there! It should read >> c:\temp\madbuild.txt, one backslash, not 2!

You can ditch the echo. | date | find /I \"Current\" >> c:\\temp\\madbuild.txt, that just creates a timestamp in the log file. A more current version would be:

Code: Select all

echo %date% >> C:\temp\madbuild.txt
...has it really been 3 years?...

HTH
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
SteveS
Senior Propellus Maximus
Posts: 2087
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: Command Line Build batch file

Post by SteveS »

More on %1:

I included it so that I could run the batch file from the command line (or another batch file :wink: ) with something like:

Code: Select all

madbuild C:\project1 C:\project2 C:\project3
And have a good coffee break. Or run it overnight, building the projects I specified.
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
MC Hammer
Sr. Propeller Head
Posts: 225
Joined: Wed Aug 08, 2007 3:04 am
Location: In a galaxy far, far away

Re: Command Line Build batch file

Post by MC Hammer »

Hi Steve and Austin
Thank you very much for your input. I will edit Steve's batch file (found the 2 backslashes a bit weird but thought there could be a valid reason for this) and try it out, and when I have time, I may give Austin's file a whirl.
Got diverted onto something else ( :evil: ) so will keep you posted when I come back to this.
Marie-Claire
Flare 2019 r2 - Windows 10 Pro - HTML5 help / "clean" XHTML output
MC Hammer
Sr. Propeller Head
Posts: 225
Joined: Wed Aug 08, 2007 3:04 am
Location: In a galaxy far, far away

Re: Command Line Build batch file

Post by MC Hammer »

ok, just to let you know that I have run both Steve's and Austin's batch files after a few issues I encountered (thanks, Steve for your help on this forum, and thanks, Austin for the PMs 8) ).
Removed the double backslashes in Steve's file and replaced all the occurrences of "C:\" by "c:\" (case-sensitive) and filled in properly the target names and custom batches in Austin's file and it all works smoothly.
So we have here two great batch files that I can certainly recommend!
Marie-Claire
Flare 2019 r2 - Windows 10 Pro - HTML5 help / "clean" XHTML output
russ
Jr. Propeller Head
Posts: 4
Joined: Tue Feb 24, 2009 12:11 pm

Re:

Post by russ »

TheGreatAndPowerfulOz wrote:Richard,

I've decided to tweak a few little things before I \"go public\", so I'll probably e-mail the BAT file to you within another day or so. Thanks!

Austin.

Looking for a copy of this new and improved bat file. Does anyone know where I can find it?

thanks
Russ
russ
Jr. Propeller Head
Posts: 4
Joined: Tue Feb 24, 2009 12:11 pm

Re: Command Line Build batch file !!found it!!

Post by russ »

Sorry for the confusion (unecessary post). I found the zip file. Now Im just sussing it out. Ill follow up with a question or three in a bit.

thanks
-Russ
:madcap:
TheGreatAndPowerfulOz
Sr. Propeller Head
Posts: 130
Joined: Mon Apr 24, 2006 12:52 pm
Location: Glen Mills, PA

Re: Command Line Build batch file !!found it!!

Post by TheGreatAndPowerfulOz »

russ wrote:Sorry for the confusion (unecessary post). I found the zip file. Now Im just sussing it out. Ill follow up with a question or three in a bit.

thanks
-Russ
:madcap:

Russ,
I'm not sure where you might have "found the zip file", but if you want to be sure you've got the latest which I've developed, just send me a Private Message through the forum with your e-mail address, and I can send it to you via e-mail.

Austin.
Austin Wright

Flare 2022 r3 (18.2.8431.26678) :: TopNav HTML5 / PDF output
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: Command Line Build batch file

Post by RamonS »

He probably downloaded the file that was attached to the post in this thread.
TheGreatAndPowerfulOz
Sr. Propeller Head
Posts: 130
Joined: Mon Apr 24, 2006 12:52 pm
Location: Glen Mills, PA

Re: Command Line Build batch file

Post by TheGreatAndPowerfulOz »

RamonS wrote:He probably downloaded the file that was attached to the post in this thread.
Right-o! I forgot that I attached it last month. :oops:

I think when I originally wrote the thing, I didn't have the ability to attach it, so was sending it via e-mail to interested parties.
Austin Wright

Flare 2022 r3 (18.2.8431.26678) :: TopNav HTML5 / PDF output
russ
Jr. Propeller Head
Posts: 4
Joined: Tue Feb 24, 2009 12:11 pm

Re: Command Line Build batch file

Post by russ »

Subject: Command Line Build batch file
doc_guy wrote:
forfear wrote:Hi!

What is a CLI? Everyone seems to know what that is. Nice post. Very important topic! We need to do something more with this. :flare:
For clarification, the purpose of the command line interface is that it allows you to build your Flare project as part of some larger script. So if you have a Windows build machine for your software, you can include a command to build and publish the Flare help system as well. Then when that completes, the script can pull over the latest version of the help system into the build.
========================================

I had a 2 questions.
1.)It looks like I can use this bat file to compile (build) but it doesnt seem to publish. Is there another parameter I need to pass to get it to publish?
My line looks like this:
madbuild -project %1 [-target OnlineAutoMoveHelp] >> "c:\Program Files\MadCap Software\madbuildlogs\madbuild.txt"
2.)When I run it I get Access denied - \ three times in the bat file window. Is this normal?

thanks
Russ
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Command Line Build batch file

Post by doc_guy »

I answered Russ in a PM, but I'll re-post my reply for all to see.

===
No, unfortunately the Madbuild.exe file won't publish your files to a publishing location. I just added code in my script to copy my files over to their published locations. (Which for me is a networked drive, not an ftp location, so this was quite easy.)

Here is my entire batch script. After that, I give you an annotated version.
svn commit c:\svn\Projects\MyProject\trunk -m "Daily update from script"
svn update c:\SVN\Projects\MyProject\trunk

cd\Program Files\MadCap Software\MadCap Flare V4\Flare.app
madbuild -project c:\SVN\Projects\MyProject\trunk\ProjectName.flprj

cd\SVN\Projects\MyProject\trunk\Output\doc_guy

cd MyProject-Install-PDF
copy Installation.pdf N:\Distribute\PrintedDocs\ /y

cd ..
cd MyProject-PDF
copy User-Guide.pdf N:\Distribute\PrintedDocs\ /y

cd ..
cd MyProject-ReleaseNotes-PDF
copy ReleaseNotes.pdf N:\Distribute\PrintedDocs\ /y

cd
o:
xcopy MyProject n:\Distribute\WebHelp\ /Y/R/H/E/I
Here is the annotated version
svn commit c:\svn\Projects\MyProject\trunk -m "Daily update from script"
svn update c:\SVN\Projects\MyProject\trunk
In this first section, I commit my changes to SVN (my source control program, with the commit message "daily update from script" (Because my source control will fail if I don't provide a commit message.)

Then I update my files from the source control to ensure I have the latest copy of all the files in my project.
cd\Program Files\MadCap Software\MadCap Flare V4\Flare.app
Here I switch directories to the MadBuild folder. You could do this in one step, but I dind't when I wrote it.
madbuild -project c:\SVN\Projects\MyProject\trunk\ProjectName.flprj
Here is where I build all my targets at once. I can't get the madbuild to only build a single project for some reason, so I just build all my targets at once.
cd\SVN\Projects\MyProject\trunk\Output\doc_guy
Now I change directories to the build location.
cd MyProject-Install-PDF
copy Installation.pdf N:\Distribute\PrintedDocs\ /y
Now I open a folder that contains a PDF deliverable and copy the file to a network drive. I don't remember what the switch does, but I think it allows me to overwrite existing files without prompting.
cd ..
cd MyProject-PDF
copy User-Guide.pdf N:\Distribute\PrintedDocs\ /y

cd ..
cd MyProject-ReleaseNotes-PDF
copy ReleaseNotes.pdf N:\Distribute\PrintedDocs\ /y
Same thing as before. I open two different directories in my output folder and copy the pdf files to a network location.
cd
o:
xcopy MyProject n:\Distribute\WebHelp\ /Y/R/H/E/I
My webhelp builds in a different location than my PDF files do, so I change to my output directory for my Webhelp, and then use the xcopy command (which is a directory copy, rather than an individual file copy command).

Again, I don't remember what the switches do, but it has to do with copying all the files in all child directories, not prompting for overwrites, and some other stuff to ensure it copies all the files and overwrites existing content.

It's not eloquent, but it gets the job done for me. I'll probably try editing it in the next few days to add logging, like Steve's does and OZ's does, because it would be nice to know if something failed along the way (like for a while, I was getting a failure when trying to update my files from source control, but I didn't know it because all the other steps worked. The problem was I was then building and publishing outdated content because it wasn't updating files properly.)

Oh, and it is probably worth noting that on my computer I have three different SVN programs installed. I have a command line SVN client that runs this script. I have PushOK's plugin so my projects work properly in Flare. And I have TortoiseSVN for working within Windows menus for using source control.

Hope this helps.
Paul Pehrson
My Blog

Image
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Command Line Build batch file

Post by doc_guy »

Oh, and I forgot to mention that my script is set up to be totally unattended. In fact, I have the bat file scheduled to run at midnight from my desktop. Our software builds at 3am, so my help files are always up to date in the daily build of the application, and the dates on the help build match the dates of the software build.

You can schedule a program using the Windows scheduler. (Shhhh... Doing this prevented me from needing to buy a build license for Flare. But I'm not saying you shouldn't buy a build license. It just saved my company a little bit of cash. YMMV.)
Paul Pehrson
My Blog

Image
russ
Jr. Propeller Head
Posts: 4
Joined: Tue Feb 24, 2009 12:11 pm

Re: Command Line Build batch file

Post by russ »

Doc_guy

Thanks for the help...Im still not understanding one thing. It seems that when I build, I produce a directory in output that looks something like this:

C:\Program Files\MadCap Software\AutoMoveHelpMain\Output\build\Temporary

In that temp dir is a DepSets and OnlineAutoMoveHelp dir...but the directories I get when I go into the GUI and PUBLISH are:

Content
Data
Skin

and a whole bunch of stuff at the top level of Output.

My question is, Is there any way through the CLI (command line) to publish built content? I have to build nightly, then I have to publish.

I looked at your script, but "I just added code in my script to copy my files over to their published locations." Implies that you are publishing manually?

thanks
Russ
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: Command Line Build batch file

Post by RamonS »

Sorry top butt in here, but yes. The line "xcopy MyProject n:\Distribute\WebHelp\ /Y/R/H/E/I" copies all the files and folders to the publishing destination (in this case a network share) overwriting anything that is there. I am not that familiar with all the switches, but one weakness of doing only this is that when something gets removed or renamed the output does not get updated correctly, it will keep the old gunk in place. That is easy to fix by running rd beforehand, so with the example from doc_guy it should be "rd /S /Q n:\Distribute\WebHelp\" before running the xcopy. That basically first wipes the publishing destination clean and then writes all files new.
alaltenburg
Sr. Propeller Head
Posts: 342
Joined: Mon Nov 03, 2008 9:33 am
Location: The heart of America

Re: Command Line Build batch file

Post by alaltenburg »

I learned about using a .bat file for building in the Flare training class. I have 26 project files that each has 2 targets (more to come) and when I leave for the night I run the .bat file. It builds all targets. Then I copy the word docs into one folder and copy the htmlhelp files to encrypt in the final software. It saves so much time, I highly recommend it.
The Moon is the first milestone on the road to the stars.

— Arthur C. Clarke
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Command Line Build batch file

Post by doc_guy »

RamonS wrote:[...]That is easy to fix by running rd beforehand, so with the example from doc_guy it should be "rd /S /Q n:\Distribute\WebHelp\" before running the xcopy. That basically first wipes the publishing destination clean and then writes all files new.
Awesome. I'm not that great with the command line, so I'll be sure to implement this. That will really help.
russ wrote: My question is, Is there any way through the CLI (command line) to publish built content? I have to build nightly, then I have to publish.

I looked at your script, but "I just added code in my script to copy my files over to their published locations." Implies that you are publishing manually?
Yep. All "Publish" does is copy files for you to a pre-determined location. The idea being this: my build directory lets me test the content that I'm writing. If, for example, my customers are getting their help from my company's webserver, I can publish directly to the webserver. But I don't want that to happen until I'm READY for it to go public. Not every build is ready for the public's eyes. So the publish feature lets you copy the content from your build directory to your publish location.

As far as I know, there is no way to "publish" using command line. However, you can copy the files over yourself, using code similar to what I use.
Paul Pehrson
My Blog

Image
forfear
Propellus Maximus
Posts: 766
Joined: Sat Feb 16, 2008 3:37 am
Location: Jungle Jingles

Re: Command Line Build batch file

Post by forfear »

there's lots of good stuff on this post particularly with regards toa more dynamic build script. did not notice this before. this is where the dynamics of the forum works really well.
automatic batch script builder
Released a little tool to help build a simple script programmatically for Flare projects.
Hope it can help authors to learn, develop your own, or simplify the batch file documentation build process.
Load a path. Save it. Run it. Schedule it.
If you submit your bug feedback request here, the more likely it'll get fixed or included in a future release
Open Utilities PageLayout Resizer for Flare/Blaze | Batch builder
TheGreatAndPowerfulOz
Sr. Propeller Head
Posts: 130
Joined: Mon Apr 24, 2006 12:52 pm
Location: Glen Mills, PA

Re: Command Line Build batch file

Post by TheGreatAndPowerfulOz »

[Updated 2009.12.16]

Hello, all.

I've had a couple of folks ask me about "expanding" the batch file I created a while ago to support more than just 12 Flare targets. That relatively small number of targets suited my needs at the time, but I suppose there are others out there who have many more targets. :shock:

I made a few tweaks, and now the "SuperSize" version of the batch file is ready for prime time! This new version allows you to specify up to 50 target names in all, and each "Batch Build" definition can include up to 50 targets each.

Now, while this batch file has worked well for me over the last couple of years, I've often thought it would be great if it could also kick off an e-mail notification to me or someone else when the build completed. Most often, I run the batch file when it's time for lunch or if I have a meeting to attend or some other reason to be out of the office (what better time to let my Flare targets compile?). After a little investigation and with the help of a couple of 3rd-party apps/utilities, I've come up with a workable solution!

With the latest version of either of these batch files, you can send an e-mail message to any number of recipients if you have the following set up:
  • Outlook installed on the machine where the batch file is executed
  • A copy of the 'mapisend.exe' executable file in the same directory as the batch file
  • The 'Express ClickYes' utility installed on the machine where the batch file is executed (automates response to Outlook's security warning about automated e-mails [available free online at http://www.contextmagic.com])
MadCapFlareBatchBuild_20091216.zip
I hope these batch files serve to simplify the lives of other Flare users out there while we wait for MadCap to give us the same functionality right in the app! :wink:

Enjoy.

Regards,
You do not have the required permissions to view the files attached to this post.
Last edited by TheGreatAndPowerfulOz on Wed Dec 16, 2009 2:08 pm, edited 1 time in total.
Austin Wright

Flare 2022 r3 (18.2.8431.26678) :: TopNav HTML5 / PDF output
SarahD
Jr. Propeller Head
Posts: 1
Joined: Tue May 19, 2009 11:21 am

Re: Command Line Build batch file

Post by SarahD »

This works great, than you so much!
SteveS
Senior Propellus Maximus
Posts: 2087
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: Command Line Build batch file

Post by SteveS »

...and welcome to the forums, SarahD :D
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Command Line Build batch file

Post by doc_guy »

Awesome.
Paul Pehrson
My Blog

Image
SteveS
Senior Propellus Maximus
Posts: 2087
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: Command Line Build batch file

Post by SteveS »

doc_guy wrote:Awesome.
But we always try to welcome new contributors to the forum...
:lol:
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Command Line Build batch file

Post by doc_guy »

LOL. That is awesome too, but not what I was referring to.
Paul Pehrson
My Blog

Image
Ken Billing
Propeller Head
Posts: 55
Joined: Mon Dec 17, 2007 11:33 am

Re: Command Line Build batch file

Post by Ken Billing »

Has anyone figured out how to modify a batch file for conditional builds? For example, only if a new topic is added or a TOC is updated, then build? I've spent a few hours at it but can't get the FOR command to return a date from %~t.

Thanks,
Ken
Ken Billing | Technical Writer
BlueCielo ECM Solutions
http://www.bluecieloecm.com

Image
TheGreatAndPowerfulOz
Sr. Propeller Head
Posts: 130
Joined: Mon Apr 24, 2006 12:52 pm
Location: Glen Mills, PA

Re: Command Line Build batch file

Post by TheGreatAndPowerfulOz »

Ken Billing wrote:I've spent a few hours at it but can't get the FOR command to return a date from %~t.
I'd never considered doing such a thing, but it sounds like a good idea!

Could you post some of the code you've got so far so we can have a look at it (maybe another set of eyes can spot some minor oversight or something)?

Thanks,
Austin Wright

Flare 2022 r3 (18.2.8431.26678) :: TopNav HTML5 / PDF output
Post Reply