I have made a plugin to interact with some exotic hardware that we use internally. This plugin depends on a third party DLL file. Lets call this file my_exotic_hardware.dll. I have successfully made the plugin work in both the editor and in runtime. My only problem right now is when I package this project the plugin DLL end up in the wrong folder.
So I every developer is forced to manually move the file from this folder to the same directory as the game executable, i.e. the root of the above path.
How do I adapt my build script so that the DLL file gets copied into the correct library during packaging? I would like to avoid the manual copy.
This is the only solution I’ve found thus far that properly copies DLL files for third party plugins to the packaged project’s Binaries folder. Thanks!
This is super old, I know, but there’s a much, much easier way, so I am going to leave this answer for anyone else looking for an answer in the future.
RuntimeDepenencies.Add actually has a 2 argument overload: (read more here)
Target destination for the DLL (in this case, the Binaries folder)
Source location for the DLL (which is the argument you would normally pass into RuntimeDependencies.Add)
Additionally, UBT provides very useful string variables that point to specific directories (read more here). In this case, what you want are "$(BinaryOutputDir)" and "$(ModuleDir)". "$(PluginDir)" can also be used instead of "$(ModuleDir)", and it points to the directory that the .uplugin is in, instead of where the .build.cs is (in my case, they’re both in the same directory).
"$(ModuleDir)" and the other string variables only work for RuntimeDependencies.Add, so don’t try using it for PublicIncludePaths.Add or any other .build.cs functions. For those, the ModuleDirectory variable is all you have as far as I know.