Visual Studio-发送“内容"文件到输出目录而不是子目录? [英] Visual Studio - sending "content" files to the output directory instead of a subdirectory?

查看:82
本文介绍了Visual Studio-发送“内容"文件到输出目录而不是子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
复制到输出目录"副本文件夹结构,但只想复制文件

Possible Duplicate:
Copy to Output Directory copies folder structure but only want to copy files

我正在使用VS2010.我有一个使用一些本机DLL的C#项目.在我的源代码树中,我将这些本机文件存储在主解决方案目录下的"DLLs"目录中.在我的C#项目中,我列出了"DLLs"文件夹,其中包含每个DLL.每个DLL都设置为生成操作内容",而复制到输出"设置为始终".

I'm using VS2010. I've got a C# project that uses a few native DLLs. In my source tree, I have these native files stored in a "DLLs" directory underneath the main solution directory. In my C# project, I have the "DLLs" folder listed with each of the DLLs inside it. Each DLL is set to build action "Content" and "Copy to Output" set to "Always".

不幸的是,由于这些文件位于子目录中,因此VS似乎认为应该以这种方式进行部署.而不是将它们部署到\ bin \ Debug,而是将它们部署到\ bin \ Debug \ DLLs.有什么简单的方法可以说服VS直接将它们部署到\ bin \ Debug,还是我必须执行某种自定义构建操作才能将它们复制到位?

Unfortunately, because these files are in a subdirectory, VS seems to think they should be deployed that way. Instead of being deployed to \bin\Debug, they're being deployed to \bin\Debug\DLLs. Is there any straightforward way to convince VS to deploy them directly to \bin\Debug, or will I have to do some kind of custom build action to copy them into place?

推荐答案

这是因为您已将它们放在解决方案的文件夹"中.务实的解决方案是将它们简单地添加到解决方案的根目录中,文件的实际位置无关紧要.这可能会在您的解决方案资源管理器"窗口中造成一些混乱.如果不能接受,则使用xcopy/d的预构建事件是解决方法.

This is because you've got them in a Folder in the solution. The pragmatic solution is to simply add them to the solution root, the actual location of the file doesn't matter. That perhaps creates a wee bit of clutter in your Solution Explorer window. If that's unacceptable then a pre-build event that uses xcopy /d is the workaround.

xcopy /d "$(ProjectDir)DLLs\*.dll" "$(TargetDir)"

这篇关于Visual Studio-发送“内容"文件到输出目录而不是子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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