When you're adding a C# project reference (let's call it LibraryProject) to another C# project (MainProject) in Visual Studio, the assembly LibraryProject.dll gets copied automatically to MainProject output directory, enabling its use in MainProject without further user intervention. How to do it, if LibraryProject is a C++ project, in a reliable and project-independent way? - that is, without manually specifying post-build events to copy resulting DLL (which location is dependent on several other settings) to main project directory (which location is also dependent on some settings, and there may even be multiple runnable assemblies in a single solution [test projects, console tools etc.], either only some or all of them needing to access LibraryProject)?
Or, as explained on an example:
In my solution there's a C++ library project (MyCppLibrary), and a C# wrapper project for that library (MyCSharpWrapper). There's also a main C# project (MyCSharpApplication) and a C# unit test project (MyCSharpTests).
When I reference MyCSharpWrapper from wither MyCSharpApplication or MyCSharpTests, I want to have not only MyCSharpWrapper.dll, but also MyCppLibrary.dll copied to respective output directories (or made accessible in some other way) of MyCSharpApplication and/or MyCSharpTests. And I want it all to happen automatically, without having to set up post-build events on MyCSharpApplication or MyCSharpTests to copy the DLLs semi-manually.
EDIT:
I'm not asking about how to call C++ code from C# - I'm aware of DllImportAttribute
and how to use it. What I want to know how to instruct Visual Studio to automatically copy MyCppLibrary.dll to output directory, when MyCSharpWrapper is referenced from another project.