Packaging non-asset directories into their own chunk?

Hello,

Is there a way to take a directory with non-.uasset files that are included in my package and assign them to their own package chunk?

In this case, I have Wwise soundbank (.bnk) files within my project’s Content directory being staged with the following ProjectPackagingSettings entry:

+DirectoriesToAlwaysStageAsUFS=(Path="WwiseAudio/Windows")

When packaging a build, they are added to the default .pak file. My intent is to generate chunks and package everything from only that directory into a pre-defined package chunk, in hopes that the .pak can be hot-swapped in the staged build for a different package chunk with banks generated separately (packaged file names and paths would all be 1:1, offsets, sizes, and hashes would be different).

I’ve organized package chunks previously by defining primary asset rules and with PrimaryAssetLabel data assets, but that doesn’t seem to be a valid solution for non-uasset files.

Could this be accomplished with a custom UAssetManager or UPrimaryDataAsset? If so, could someone please point me to some examples of using the AssetManager to define non-.uasset files as primary assets?

1 Like

Bump, I have the same issue, did you find any solutions?

Funnily enough, that was my exact question and I came here for answers, and I found one! Just a quick remark before going into the details:

Packaging API files into .pak files is not always a good idea. I don’t know about wwise, but with fmod at least there’s a big warning to not do that, although it is supported. The issue is file/read locks while accessing the files in the .pak. It’s always good to test things out before shipping, but that should be obvious, I believe.

The answer to your question is as follows, in addition to +DirectoriesToAlwaysStageAsUFS:

You can use the DefaultPakFileRules.ini config file to specify the chunk for the files. Your file can look like this:

[MyMovieFiles]
OverridePaks="pakchunk1"
bOnlyChunkedBuilds=true
+Files=".../*.mp4"

See also Engine/Config/BasePakFileRules.ini for the few lines of documentation that exists there. There are plenty of other possibilities with that.

However, one other remaining point is very important when doing that: You can only package those files into a .pak file that “already exists”. This means, you can’t just specify "pakchunk5" and then the file will be generated, you have to make sure that – by normal packaging routines – the pakchunk5 exists. You can do that by making sure that one asset is packaged into that chunk, for example by adding a PrimaryAssetLabel data asset that’s a runtime label and assigned to chunk 5. Using the Asset Audit you can see which chunks exist.

I assume that you can theoretically pack your files in any custom-named chunk you want, but you somehow need to make sure that the chunk will actually be built. This is true for all chunks that exist via asset management (aka “pakchunkN” chunks).

Important also: I tried figuring this out by myself since there’s almost no documentation about it. Most documentation I found was the file BasePakFileRules.ini file mentioned above, as well as Engine/Source/Programs/AutomationTool/Scripts/CopyBuildToStagingDirectory.Automation.cs. I might be very wrong in certain parts and there might be other solutions to pack non-asset files in your custom chunk.

2 Likes

You’re a lifesaver

How do I specify specific files like /Game/Config/DefaultEngine.ini? Is it +Files="/Game/Config/DefaultEngine.ini" or something else?

Probably not exactly like that, but similar. Let me explain:

/Game/Config/DefaultEngine.ini is a very weird path: It starts with /Game/... which suggests a content directory. You usually have the content directory directly next to your MyProject.uproject file (simply named Content), which is mapped to a virtual Unreal filesystem (or something like that) as /Game/..., so a file inside the content folder named ABC.uasset can be referenced as /Game/ABC. You very likely don’t have your config files inside that content directory, but next to it.

The next big thing is, you (most probably) don’t want to pack your DefaultEngine.ini file into the pak. Unreal has its own solution for including the config files in a packaged game (I don’t know the details here, but the configs are in fact there).

+Files= is most probably a relative path, the question is, relative to what. Sometimes Unreal has relative paths to the .uproject file, sometimes to the /Game/ content directory. Maybe the mentioned Engine/Config/BasePakFileRules.ini file has more detail on that. I also already deleted my test project which had that config, sadly, but I’d first try with relative to the /Game/ content directory. It’s also possible (or maybe even likely) that packaging only works for files within that game content directory (or other content directories, like engine, plugins, …), so it’s possible that you can’t even package content outside the content directory. I’d have to check the sources first to find out more

So, for packaging a file in Content/MyFolder/MyTestFile.txt I’d start testing with +Files="MyFolder/MyTestFile.txt", but you have to test it; I might be wrong.

The sample BasePakFileRules.ini file makes me think that paths relative to the config directory might also work. Good luck finding the correct answer (let us know :slight_smile:)

1 Like