This is a few months old, but since nobody has answered you, there are 2 steps:
- Copy the .dll file into the Binaries folder
- Adding the copied DLL to the runtime dependencies.
Everything below goes into your .build.cs file.
First, a couple helper functions to copy the DLL:
public string GetUProjectPath()
{
return Path.Combine(ModuleDirectory, "../../../..");
}
private string CopyToProjectBinaries(string Filepath, ReadOnlyTargetRules Target)
{
string BinariesDir = Path.Combine(GetUProjectPath(), "Binaries", Target.Platform.ToString());
string Filename = Path.GetFileName(Filepath);
//convert relative path
string FullBinariesDir = Path.GetFullPath(BinariesDir);
if (!Directory.Exists(FullBinariesDir))
{
Directory.CreateDirectory(FullBinariesDir);
}
string FullExistingPath = Path.Combine(FullBinariesDir, Filename);
bool ValidFile = false;
//File exists, check if they're the same
if (File.Exists(FullExistingPath))
{
ValidFile = true;
}
//No valid existing file found, copy new dll
if (!ValidFile)
{
File.Copy(Filepath, Path.Combine(FullBinariesDir, Filename), true);
}
return FullExistingPath;
}
Next, make the DLL a dependency so it gets copied automatically:
string pluginDLLPath = PATH_TO_YOUR_DLL_FILE;
string binariesPath = CopyToProjectBinaries(pluginDLLPath, Target);
System.Console.WriteLine("Using Python DLL: " + binariesPath);
RuntimeDependencies.Add(binariesPath);