Post-build event command

This forum is for all Flare issues not related to any of the other categories.

Post-build event command

Postby gbv34 on Mon Apr 19, 2021 2:31 am

Hello,
I'm trying to implement post-build event command for a PDF target.
My goal is simple. I just want to copy the PDF published from the Output directory to another directory.
i used this command for this:
Code: Select all
for %I in "$(OutputDirectory)\*.pdf" do copy %I in (C:\Users\User\Contacts\Desktop\) /Y

However, it continues to warn me that there's no destination selected and the publish process is skipped.

Any idea where my command line is incorrect?

Thanks a lot for your feedback!
gbv34
Jr. Propeller Head
 
Posts: 3
Joined: Sat Dec 19, 2020 8:20 am

Re: Post-build event command

Postby Dave Lee on Tue Apr 20, 2021 12:46 am

You're talking about two different things here.

A post-build event is nothing to do with publishing.

A post-build event happens after you build the target - and it will run regardless of whether you also publish the target after the build.

When you Publish in Flare, it will try and copy your output to the Destination location. You have to create the destination in Project Organizer, and select the destination in the target's Publishing tab.
So you're seeing that error because you're trying to Publish the target, but you haven't set a publish destination for that target.

By the looks of it, you've created a post-build event to do exactly the same thing as what you could do just using a publish destination. So I'd suggest using a publish destination rather than a post-build event.

See the help: https://help.madcapsoftware.com/flare20 ... Output.htm
Dave Lee
Master Propellus Maximus
 
Posts: 5961
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Post-build event command

Postby gbv34 on Sun Apr 25, 2021 8:28 am

Hi David,
Thanks for your feedback. Actually, the example I provided was intentionally simple and a way to understand the principle of post-event builds. I agree, it is easier to implement it in the "Publish destination", however my point is more to understand how it works. If I understood your explanation, my event should be something like:
Code: Select all
cp %I in "$(OutputDirectory)\*.pdf" $(OutputDirectory) Destination location


I'm not sure if it works, however it makes sense to me. The problem lies less in Flare than mastering shell commands :shock:
gbv34
Jr. Propeller Head
 
Posts: 3
Joined: Sat Dec 19, 2020 8:20 am

Re: Post-build event command

Postby Dave Lee on Mon Apr 26, 2021 1:04 am

I'm not sure you did understand.

gbv34 wrote:However, it continues to warn me that there's no destination selected and the publish process is skipped.


That error has nothing to do with the command in your post-build event.
You're seeing that error because you're trying to Publish a target, and you can't publish a target without setting a destination.

When you Build your target (not Publish it), the post-build event will run at the end of the build.
If you think your post-build event isn't working, then maybe check the build log for errors (although I'm not sure if you'll see errors for a command line).
Dave Lee
Master Propellus Maximus
 
Posts: 5961
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Post-build event command

Postby robdocsmith on Mon Apr 26, 2021 4:54 pm

I had a little play with the idea...

The post-build command:
Code: Select all
for %I in "$(OutputDirectory)\*.pdf" do copy %I "C:\Users\<username>\Desktop"


Runs correctly but nothing is copied to my desktop. My guess is it can't interpret the list of files in the source part of this command. In Madcap's example they have a specific list of files in parentheses instead of a wildcard.
In your command you aren't supplying a destination address correctly - needs to be in quotes (see examples on https://help.madcapsoftware.com/flare2020r3/Content/Flare/Step4-Developing-Targets/More/Creating-Pre-Post-Build-Events.htm)

As Dave said, for a simple copy of output to a destination address, I'd use Publish destinations in the project and the Publish command. Works a treat.

If you wanted to do more complicated stuff such as combining your output with other PDFs and packaging into a ZIP for distribution, I'd do it all in a batch file and just call the batch file as a post-build command.

For example, the post-build command:
Code: Select all
C:\Users\<username>\Desktop\mybatch.bat

and a batch file containing:
Code: Select all
xcopy "<sourcepath>\*.pdf" "<destinationpath>"

Will copy all PDFs from source to your destination after a build. Using a batch file means you can do all sorts of more creative things with your files after a build operation including calling other scripts or doing other file manipulations.
robdocsmith
Sr. Propeller Head
 
Posts: 119
Joined: Thu May 24, 2018 3:11 pm


Return to Flare's General Discussion

Who is online

Users browsing this forum: Google [Bot] and 18 guests