I have a plugin that I needed to package to use only the public part in other projects, I created a project in version 5.1 and installed the plugin there and started packaging it. Because my plugin depended on another one I had to install the source of the engine, put the other plugin into the engine and package it using the engine’s BuildPlugin command. As a result, the plugin is packaged and works in another project, but only in the Development Editor configuration. Because when I run the project in DebugGame Editor for example, I get an error that I can’t find the .lib file for this configuration in the Intermediate plugin folder. My question is how can I package the plugin to run it under any configuration?
I tried:
Setup the .uplugin
Setup the BuildPlugin command
Use different combinations, e.g. list of configurations only in .uplugin or in BuildPlugin, together, nowhere.
I was scratching my head on this issue for a couple hours trying to figure out how to do this without modifying the engine (the Stack Overflow link above shows that the BuildPlugin command is hardcoded to Development and Shipping configurations). Ultimately the “easiest” thing is for Epic to fix the underlying problem OR for you to modify your engine.
This is kind of impractical for most people, but since I put in the effort (I am working in a scenario where I don’t want to distribute source code) I figured I would share. If you are willing to do some powershell scripting you can also get DebugGame forced into your packaged Plugin. Each thing below that is <BetweenAlligators> is a path you have to figure out for your setup. Also I tested this on Unreal 5.3.2, but this will probably work for other UE5 versions as well.
Package the plugin and include the secret option -NoDeleteHostProject. Note down how Unreal Built Tool (UBT) is called (it should be executing a dotnet.exe with an UnrealBuildTool.dll supplied as the first argument).
In <ArchiveLocation>\HostProject there is a “HostProject” that gets created. This is an intermediate project used just for the packaging process. Augment the HostProject with an empty C++ Module (which I called HostProject for simplicity). An easy way do this is to create a empty Unreal C++ project through the Launcher and copy + rename the files over.
Execute UBT to generate project files on the HostProject to create a sln file. You can open up the solution and try to build to verify you did everything correctly.
Generate a manifest for the Plugin. Note: you would expect this step to actually build in DebugGame, but there appears to be an oversight in UBT where it ignores you and does Development instead. Very annoying. We still want the Manifest file so we know which files to copy over.
Read in the manifest file, copy over the files it lists to their final destination, and then patch the .precompiled file. Since everything is wrong and points to Development output we need to apply some fixups. Powershell snippet:
$ManifestContents = New-Object xml
$ManifestContents.Load("<ManifestFile.xml>")
$HostProductPrefix = Resolve-Path "<HostProject>\Plugins\<YourPlugin>"
$FinalProductPrefix = Resolve-Path "<ArchiveLocation>"
foreach ($Item in $ManifestContents.BuildManifest.BuildProducts.string) {
$NewPath = $Item.Replace($HostProductPrefix, $FinalProductPrefix).Replace("Development", "DebugGame")
if ($Item -ne $NewPath)
{
Write-Host " ... Build Product:" $Item "==>" $NewPath
# Force create the directory structure if it doesn't exist
New-Item -ItemType File -Path "$NewPath" -Force | Out-Null
# Copy the item to the destination
Copy-Item -Path "$Item" -Destination "$NewPath" | Out-Null
# Note: the ".precompiled" file is pointing to the wrong locations (Development ==> DebugGame)
if ($Item.EndsWith(".precompiled"))
{
(Get-Content "$NewPath") | ForEach-Object {
$_.Replace("Development", "DebugGame") # send the current line to output
} | Set-Content "$NewPath"
}
}
}
Delete the HostProject so it doesn’t get included along with your plugin.
Haha, that’s a lot of steps to get something that seems like it would be simple. Good luck to future developers who have this same issue. You can test that you did it right by installing your plugin into a fresh sample project and using the Project Launcher to build in DebugGame configuration on-the-fly.