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.
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: 2089
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: 2089
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
Ken Billing
Propeller Head
Posts: 55
Joined: Mon Dec 17, 2007 11:33 am

Re: Command Line Build batch file

Post by Ken Billing »

The crux of the batch file is the following line that lists the topic files in ascending date order so that the newest is listed last. The FOR statement should set the environment variable NewestTopicDate to the date/time of each file, resulting in the variable being set to the date/time of the newest file. The problem is that the %~t substitution reference doesn't work as it should. I've tried several other of the substitution references and they work fine. Perhaps its a data formatting issue, I don't know. I had to set this aside and get some real work done. :wink:

Code: Select all

FOR /F "delims=" %%I IN ('DIR /B /O:D "Content\*.htm"') DO SET NewestTopicDate=%%~tI
The batch file could contain a similar line to do the same for the Project\TOCs folder to set another environment variable to the date of the newest TOC. Yet another line will do the same for the target folder output file.

Next, a line similar to the following will compare the dates to determine if the target is outdated and if so, execute a build.

Code: Select all

 IF /I %NewestTopicDate% GTR %NewestTargetDate% (
madbuild.exe -build MyProject.flprj -target MyTarget >> BuildResults.log
:: Add build completion line to log
echo Project build completed >> BuildResults.log

:: Begin FTP transfer
FTP -s:MyScript.ftp

:: Add transfer completion line to log
echo Build transferred to FTP >> BuildResults.log
)
The code above is somewhat simplified for clarity.
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 »

Well, at long last the glory days of the .BAT file are over! Flare V6 now offers batch building/publishing of project targets.

I just installed Flare V6 and tried it out; works great! Hooray!! :D
Austin Wright

Flare 2022 r3 (18.2.8431.26678) :: TopNav HTML5 / PDF output
Ken Billing
Propeller Head
Posts: 55
Joined: Mon Dec 17, 2007 11:33 am

Re: Command Line Build batch file

Post by Ken Billing »

I submitted an enhancement request for conditional builds, by the way. Maybe 7?
Ken Billing | Technical Writer
BlueCielo ECM Solutions
http://www.bluecieloecm.com

Image
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: Command Line Build batch file

Post by NorthEast »

TheGreatAndPowerfulOz wrote:Well, at long last the glory days of the .BAT file are over! Flare V6 now offers batch building/publishing of project targets.

I just installed Flare V6 and tried it out; works great! Hooray!! :D
I had a look too, seems to work ok.

One thing I did notice - when I add the target batch file, Flare wants to include it in source control.
Now thinking ahead, if I did that, that'd mean everyone working on the project would also have a local copy of the batch target too. So wouldn't that cause numerous simultaneous builds on all our PCs, all trying to publish to the same folder?
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 »

Dave, your logic there is sound. I think you're right. It would.

You might want to exclude that file type from your repository, so it never gets picked up.
Paul Pehrson
My Blog

Image
Post Reply