Pre/Post build step in UBT

How can we determine the target directory in the build step? e.g. copy a file from the project folder to the package folder.

UnrealBuildTool just compiles stuff; packaging is done but a tool called AutomationTool (or UAT for short).

If you want to include a file from the source directory when itā€™s packaged, you can mark it as a ā€œruntime dependencyā€ from a .build.cs file. There are plenty of examples of that if you search for ā€œRuntimeDependencies.Addā€.

I have a plugin that needs some runtime file resources.

in my ā€¦Build.cs Iā€™ve added those files a RuntimeDedepdency. When I hit Launch in UE4 and watch the log I can see that it tries to copy those files, but every time fails with ā€œAccess to the path ā€¦ is denied.ā€

Iā€™ve the path and itā€™s correct.

Any ideas how to do this? Seems needlessly difficult.

Thanks.

Hey so, I had to spend some time figuring this out, since everyones wrong-

{
	"FileVersion": 3,
	"EngineAssociation": "{D6ABF944-42D3-E058-D1F4-5195E5D7E272}",
	"Category": "",
	"Description": "",
	"Modules": [
		{
			"Name": "Doomsday",
			"Type": "Runtime",
			"LoadingPhase": "Default",
			"AdditionalDependencies": [
				"CoreUObject"
			]
		}
	],
	"PostBuildSteps":
		{
			"Win64": [
				"copy \"C:\\dev\\projName\\Binaries\\Win64\\DoomsdayServer.exe\" \"C:\\dev\\Doomsday\\Binaries\\Win64\\WindowsNoEditor\\projName\\Binaries\\Win64\\\"", "echo Exported Server file successfully!"
			]
		}
}

This is JSON, we must treat it as so. Thank me later :wink:

Worked for me at UE4.16.2 ! Yeeeeei. Thank you for clarifying that UE has more JSON tags, than it actually generates.

@

Is $(ProjectDir) the directory of the .uproject file or the directory of the build output? Can you provide a link to UEBuildTarget.cs ?

Ok, so I was actually able to find a UEBuildTarget.cs at https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildTarget.cs#L2795 ā€¦ I assume thatā€™s the right oneā€¦

As of Sept, 2018, the available variables are

$(RootDir): C:\Program Files\Epic Games\UE_4.20

$(EngineDir): C:\Program Files\Epic Games\UE_4.20\Engine

$(EnterpriseDir): C:\Program Files\Epic Games\UE_4.20\Enterprise

$(ProjectDir): C:\my_ue4_proj

$(TargetName): my_ue4_proj

$(TargetPlatform): Win64

$(TargetConfiguration): Development

$(TargetType): Game

$(ProjectFile): C:\my_ue4_proj\my_ue4_proj.uproject

$(PluginDir): undefined

Which means that there is no variable for the output build directory? How can we reference this directory?

1 Like

I would have expected anything placed into

$(ProjectDir)\\Binaries\\$(TargetPlatform)

in the ā€œPostBuildStepsā€ will find itā€™s way into the build output at

<BuildOutputDir>\WindowsNoEditor\<ProjName>\Binaries\<TargetPlatform>

but I was proven wrong. I canā€™t seem to find a way to place a file in the packaged output.

1 Like

Issue UE-34899 has vanished without a trace

Any news on how to place a file in the packaged output?

Bumping this.

Canā€™t use RuntimeDependencies as it does not preserve directory structure on the platform weā€™re building for. Would need to copy files from project directory to the packaged build. I found a way to get RuntimeDependencies working correctly by commenting out some lines in the source code, however, this is not feasible for a distributed plugin. Any ideas?

Bump.