Copy 3rd Party DLLs to Binaries folder does not work for Engine Plugin - How to solve?

Hey there, coincidentally found your post after messing with RuntimeDependencies.Add for a few hours. I’m not doing anything with the marketplace, but since I spent an unreasonable amount of time messing around thought I’d share my experience.

Having a 3rdparty library with a DLL and wanted it to be copied over. Documentation states to use $(TargetOutputDir) but the file doesn’t appear where my executable is in \Binaries\Win64. It certainly doesn’t do what I expect it to do, maybe it does copy it to some unexpected location - no clue.

Eventually tried $(PluginDir) and that worked copying the dll to the folder with the .build.cs file, as expected (still the wrong location, but at least something was copied - so I could at least rule out that the source path was wrong).

Then tried $(BinaryOutputDir) and with that the file does land next to the executable in \Binaries\Win64. I’m still a bit hesitant about using $(BinaryOutputDir) instead of $(TargetOutputDir), but so far it does what it’s supposed to do.

As a hack, you could copy it in the target.cs file in the postbuild step. I dislike that approach, but depending on how desperate you are it might be worth a try:

private void ImplPostBuildCopy(string SrcPath, string DestPath)
{
    PostBuildSteps.Add(string.Format("echo Copying {0} to {1}", SrcPath, DestPath));
    PostBuildSteps.Add(string.Format("xcopy /y /i /v \"{0}\" \"{1}\" 1>nul", SrcPath, DestPath));
}

and call it with

ImplPostBuildCopy(“$(ProjectDir)\source\Plugins\xxx\sdk\bin\win64\yyy.dll”, “$(ProjectDir)\Binaries\$(TargetPlatform)\”);