Third party dll copy in plugin build script

I was not sure which category this post should be in, but I hope this is OK.

I am co-developing a plugin and have some questions regarding third party dll’s.
I would like the dll’s (and some other binary files) that the plugin depends on to be copied to whatever build target is currently being built, whether it be building an executable from a project using the plugin or if the plugin itself is being packaged for distribution.
The natural way, it seems to me, would be to have some logic in a …Build.cs file that does a number of File.Copy(source, target). The problem I am facing there is that I have not found a way to get the build target path from …Build.cs.
To give a clear example: lets say I have an Unreal Editor project that uses the plugin. Then, I build an executable from the project by selecting (in the Editor) File->Package Project->Windows. Then I specify the target path to some random place in my computer in the browsing window that pops up. When the …Build.cs script (of the plugin) is called, I would like to get hold of that random path selected so that I can copy the dll’s there. Is there a way to get that path?

Currently, since this has not worked, the RuntimeDependencies.Add() is used instead to get the dll’s copied to the correct location by doing: *RuntimeDependencies.Add("$(BinaryOutputDir)", source_path); *
This copies the files to the target build location correctly, but it does so in places where it is not desirable, for example when re-compiling an Unreal Editor c++ project which depends on the plugin. In that case the *RuntimeDependencies.Add("$(BinaryOutputDir)", source_path) *in the plugins …Build.cs file will copy the dll’s to the projects local Binary directory, which is not the intended behavior. Really, I would like not having to use *RuntimeDependencies.Add() *as a mechanism for file copy, is there a better, or should I say “correct”, way?

There’s pre/post build steps you can hook to from .uproject file



"PostBuildSteps":
{
    "Win64": 
        "copy $(ProjectDir)\Binaries\$(TargetPlatform)\$(TargetName).exe D:\SomeDir"
    ]
}


And they can also be used from Build.cs files

PreBuildSteps (List<String>)
PostBuildSteps (List<String>)

Thank you for the reply, I will check if this might be useful for my situation.

Update; I experimented a little with the “PostBuildSteps” as mentioned above, but it seems that when building an executable from a project that uses the plugin, none of the available variables will point to the actual target location. To be clear: I select (in the Editor) File->Package Project->Windows. Then I specify the target path, lets say to C:/Users/Me/Desktop/MyBuild.

I did:



"PostBuildSteps": {
"Win64": 
"echo projectDir: $(ProjectDir)",
"echo TargetName: $(TargetName)",
"echo TargetConfiguration: $(TargetConfiguration)",
"echo TargetType: $(TargetType)",
"echo ProjectFile: $(ProjectFile)",
"echo PluginDir: $(PluginDir)",
]
}


But none of the baths printed out at the end of the build points to my target location (the MyBuild path mentioned above) when building an executable (cooked build).
For this it seems that only $(BinaryOutputDir) points to the actual target location, but that is only available in combination with the “RuntimeDependencies.Add(dest, source)” which is what I am trying to avoid.

So the question then becomes: is there some other mechanism for ensuring that third party dll’s that the plugin depends on is copied to the target location in the case where one is building an executable (.exe) from an Unreal Editor project that uses the plugin?