I have a C# GUI application that references a Managed C++ project, which requires 7 native C++ DLLs. I'm looking for the cleanest method for copying these 7 DLLs to the final project output.
What works
Add all DLLs to the C# applications, specifying:
Build Action == "Content"
Copy To Output Directory == Copy Always"
This will make the base folder of the project a mess of DLLs in some cases, all of which are requirements of referenced projects, and not that project itself.
What does not work
What is the best solution in this case? I'd prefer the Managed C++ project to be able to handle it's own DLL requirements if possible, and preferably in a way that won't prevent the project from being used across multiple applications.
As far as having a clean project goes, is it better to insert all my code files within subfolders in the project, and have the DLLs at the root to make the first solution work?
Solution:
Using the post-build suggestion from Joseph, the following command does the trick to use a "Required DLLs" folder.
xcopy "$(ProjectDir)Required DLLs*.*" "$(TargetDir)" /Q /Y
/Q hides the individual files from the output, and /Y suppresses overwrite prompts.
You can use a post-build event to copy the contents of a directory (e.g., your "Required DLLs" directory) into the project's output directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With