I’m calling a non-.NET dll from my project using P/Invoke, meaning that the .dll must always be present in the .exe’s directory.
Is there any way to tell Visual Studio of this dependency, so that it will automatically copy the .dll to the output directory when compiling, and will automatically include the .dll in the setup? Or do I have to do this manually?
You can copy/link this file(s) to the project, and in properties windows set ‘Build Action’ to ‘None’ and ‘Copy to Output Directory’ to ‘Copy if newer’ or ‘Copy always’.
Or you can use a ‘Pre-Build Events’ & ‘Post-Build Events’ where you can specify any batch scripts.
I prefere the second option, because this way is more flexible than the first.
Also you can modify a MSBuild file and add a task for copy the file(s).