Plugin types stripped out of build when packaged into game

There appears to be an issue when packaging a Source code plugin with a project: If the DefaultEngine.ini contains a section that loads the plugin


Then when packaging that project the UBT will generate a PluginName-Static-Win64.lib version of the plugin (instead of compiling it monolithically into the game .exe) and then link that against the the generated .exe. The problem with that is that all the Unreal generated meta-data and classes get dead-code stripped out because there aren’t any direct linkages to those types (consider the case where a game code project doesn’t reference all, or even any of the types in the plugin, rather blueprint and uasset data references the types). (NOTE, if that line is actually in GameProject/Saved/Config/Engine.ini it does not cause a Static lib version of the plugin to be created, the library is properly packaged into the game by being compiled in-line)

I solved this in my case with a giant hack where I provide a macro that can be included in the game project that calls StaticClass() on all the types exported in my plugin from the static constructor of an object.