Say, that we have .NET application App
along with additional assembly ClassLibrary
, which, in turn, uses native DLL called Library
. All these are in single solution, so I may set up the dependencies etc.
The catch is, that I want the Library
to be automatically "attached" to ClassLibrary
, such that when my App
references it, Visual Studio will automatically copy the Library
to target bin folder.
Usually I did that by using pre-build or post-build events and adding custom scripts. But hey, all these are in the same solution. Is there simpler way to keep such native-dll-reference for .NET assembly?
You have to add the native library to your project. If the native library is in the Solution (not in the project) than it is there only for your reference. You have to add the native library to the Project because the project file describe the build behaviour.
Than add native assembly to the ClassLibrary project and then in properties set:
Copy To Output Directory
toCopy if newer
orCopy always
.