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

Hey everyone!

I’m struggling with a very strange problem and I already tried out everything that I could imagine but still the problem persists and I hope that you guys can help me.

I built a code plugin that uses some Third-Party DLLs. It works perfectly as a project plugin and copies over the needed DLLs to the Binary folder using

            RuntimeDependencies.Add("$(BinaryOutputDir)/depthengine_2_0.dll", depthEngineDllPath);
            RuntimeDependencies.Add("$(BinaryOutputDir)/k4a.dll", k4aDllPath);
            RuntimeDependencies.Add("$(BinaryOutputDir)/k4abt.dll", k4abtDllPath);

However, as an engine plugin on the UE Marketplace, this does not work anymore. I already tried out multiple things, e.g.:

            RuntimeDependencies.Add("$(TargetOutputDir)/depthengine_2_0.dll", depthEngineDllPath);
            RuntimeDependencies.Add("$(TargetOutputDir)/k4a.dll", k4aDllPath);
            RuntimeDependencies.Add("$(TargetOutputDir)/k4abt.dll", k4abtDllPath);

            RuntimeDependencies.Add("$(PluginDir)/Binaries/Win64/depthengine_2_0.dll", depthEngineDllPath);
            RuntimeDependencies.Add("$(PluginDir)/Binaries/Win64/k4a.dll", k4aDllPath);
            RuntimeDependencies.Add("$(PluginDir)/Binaries/Win64/k4abt.dll", k4abtDllPath);

But still the DLLs are not copied over. I am pretty sure that the paths (k4aDllPath etc.) are correct:

string sdkPath = Path.GetFullPath(Path.Combine(PluginDirectory, "Source/ThirdParty/azure-kinect-sdk"));
string k4aDllPath = Path.Combine(sdkPath, "sdk", "windows-desktop", "amd64", "release", "bin", "k4a.dll");

What am I missing? Or how can I debug this problem best?

I really hope that you guys can help me and I’m looking forward to any helpful answer!!

Anyone?? :confused:

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)\”);