How to add directory to cook programatically?

We have a plugin and we want to make sure that Content folder of the plugin always gets cooked in any project that plugin is used. I was hoping there would be some way to specify directories to cook in Build.cs for plugin but can’t find anything related in the docs. Any pointers would be helpful!

I have not actually done this myself but I have seen plugins referencing the needed assets during their StartupModule.

From LoadingScreen plugin:

void FLoadingScreenModule::StartupModule()
{
[...]
		// Load for cooker reference
		const ULoadingScreenSettings* Settings = GetDefault<ULoadingScreenSettings>();
		for ( const FStringAssetReference& Ref : Settings->StartupScreen.Images )
		{
			Ref.TryLoad();
		}
[...]

https://github.com/ue4plugins/LoadingScreen/blob/master/Source/LoadingScreen/Private/LoadingScreenModule.cpp

Could be something you might be interested in.

You might be able to add an entry for ‘PrimaryAssetRules’ (in the [/Script/Engine.AssetManagerSettings] section) in the game config file for your plugin and have the CookRule=AlwaysCook for the assets that you always want to cook.