指定在Visual Studio中non-.NET依赖 [英] Specifying a non-.NET dependency in Visual Studio

查看:195
本文介绍了指定在Visual Studio中non-.NET依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打电话从我的项目中使用P / Invoke,这意味着该.dll必须始终present的.exe文件的目录non-.NET DLL。

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.

有没有办法告诉这种依赖性的Visual Studio,使之在编译时.dll文件自动复制到输出目录,并会自动包含在安装该.dll?还是我不得不手动做呢?

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?

推荐答案

您可以将此文件(S)拷贝/链接到项目,并在属性窗口设置生成操作为无和复制到输出目录复制,如果新或始终复制。

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".

或者你可以使用一个pre-生成事件及放大器; 生成后事件在这里你可以指定任何批处理脚本。

Or you can use a "Pre-Build Events" & "Post-Build Events" where you can specify any batch scripts.

余prefere第二种选择,因为这种方式比第一更加灵活。

I prefere the second option, because this way is more flexible than the first.

你也可以修改的MSBuild文件,并添加一个任务复制的文件(S)。

Also you can modify a MSBuild file and add a task for copy the file(s).

这篇关于指定在Visual Studio中non-.NET依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆