Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Run a custom command before build

I would like to insert a custom build step (e.g. running a batch file) before the compilation begins. How would I go about adding a custom build step to the build process.

Product Version: Not Selected
more ▼

asked Sep 15 '14 at 01:11 PM in Packaging & Deployment

avatar image

651 44 59 91

avatar image thk123 Sep 15 '14 at 01:13 PM

Sorry for the duplicate, it said it had failed.

avatar image Shadowriver Sep 15 '14 at 01:52 PM

UE4 has it own building system called UBT and uses c# build script which you can find in source, you might try to plug yourself there

avatar image thk123 Sep 15 '14 at 02:52 PM

Yeah, I've been looking through the ModuleRule.cs to see if there was a custom commands list. I was hoping to not have to make any changes to the UBT itself since I'd have thought this was a fairly standard requirement to be able to hook custom rules in to the pipeline.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Inspired by Shadowriver's comment I have come up with a very hacky solution and would very much like to see the proper way of doing it.

I realised that the constructor from the projects ModuleRules must be executed so I just bunged a Process.Start into there.

There are a few caveats:

Firstly, this is called twice in a build, so if your operation is time consuming this could be a problem.

Secondly, if you launch a batch file the working directory will be [Unreal Engine Location]\Engine\Source. To get the path, I came up with another awful hack of a solution:

 StackTrace st = new StackTrace(new StackFrame(true));
 StackFrame sf = st.GetFrame(0);
 string fileName = sf.GetFileName();
 DirectoryInfo ContaingingDirectory = new DirectoryInfo(Path.GetDirectoryName(fileName));
 DirectoryInfo CorrectDirectory = ContainginDirectory.Parent.Parent;

The CorrectDirectory is the root directory of your project.

more ▼

answered Sep 17 '14 at 03:09 PM

avatar image

651 44 59 91

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question