简体   繁体   English

在Visual Studio中,我不想提交Debug文件夹,但其中包含dll文件,如果我将其移动,则项目将无法编译

[英]In Visual Studio, I don't want to commit my Debug folder, but it has the dll file in it, and if I move it project won't compile

What should I do? 我该怎么办?

Basically, I want to commit my Visual Studio 2012 project, but it has a Debug folder in it that we traditionally don't commit. 基本上,我想提交我的Visual Studio 2012项目,但是其中有一个Debug文件夹,而我们通常不会提交。 Only problem is that the Debug folder has the project's dll in it, and if I move the dll to the folder's parent, the project no longer compiles. 唯一的问题是,Debug文件夹中包含项目的dll,并且如果我将dll移至该文件夹的父文件夹,则该项目将不再编译。

So here's the structure: 所以这是结构:

Project Folder > MSVC_2012 > Debug folder, sln file, etc. 项目文件夹> MSVC_2012>调试文件夹,sln文件等

And in that Debug folder is the dll. 而在Debug文件夹中是dll。 How do I move that out of the Debug folder into MSVC_2012? 如何将其从Debug文件夹移至MSVC_2012?

Your question isn't entirely clear on details, but here are some options (and ways you could improve the question): 您的问题在细节上并不完全清楚,但是这里有一些选择(以及改进问题的方法):

  • Your question looks like an XY problem . 您的问题看起来像XY问题 You stated that "if I move the dll to the folder's parent, the project no longer compiles." 您说“如果我将dll移到该文件夹​​的父目录,该项目将不再编译。” in which case the real problem here is why it isn't compiling. 在这种情况下,真正的问题是为什么它不编译。 We'd need more details to figure out why. 我们需要更多细节来找出原因。 You also need to be clearer what you mean by "if I move the dll" - you can't "move" a DLL before it is compiled, and if you move it afterwards, then by definition the compiling worked, so actually your statement as it stands doesn't make sense. 您还需要弄清楚“如果我移动dll”的含义-在编译DLL之前不能“移动” DLL,如果在之后移动它,那么按照定义,编译起作用了,所以实际上您的语句就目前而言,这没有任何意义。 In any case, you should probably focus on fixing your broken build rather than fiddling with it to meet the needs of your version controlling. 无论如何,您可能应该专注于修复损坏的构建,而不是为了满足版本控制的需求而摆弄它。

  • You haven't specified why it is a problem for the DLL file to be in the Debug folder. 您尚未指定DLL文件在Debug文件夹中的问题所在。 I assume it's because you want to commit it to your VCS (which you didn't explicitly state as your goal). 我认为这是因为您想将其提交到您的VCS(您并未明确声明为目标)。 In which case, are you aware that it is not normal practice to commit the binary output of your code? 在那种情况下,您是否知道提交代码的二进制输出是不正常的做法? So one solution might be to reconsider why you are trying to commit the DLL in the first place. 因此,一种解决方案可能是重新考虑为什么要首先尝试提交DLL。

  • You didn't specify which VCS you're using. 您没有指定要使用的VCS。 In Git (and I assume in most other VCS') you can have finer grain control over what to exclude from commits than whole folders. 在Git中(我假设在大多数其他VCS中),与整个文件夹相比,您可以更好地控制要从提交中排除的内容。 So, another option is to configure your VCS to ignore the Debug folder with the exception of any DLL files contained inside it. 因此,另一种选择是将VCS配置为忽略Debug文件夹,但其中包含的所有DLL文件除外。

  • You can change where MSVC places your DLL file in the project property pages under Configuration Properties -> General -> Output Directory . 您可以在Configuration Properties -> General -> Output Directory下的项目属性页中更改MSVC将DLL文件放置在何处。 Presumably this is what you meant when you referred to "moving" the DLL? 想必这就是当您提到“移动” DLL时的意思吗?

  • Finally, as per other people's comments on your question, if you want the DLL to be in both places you can use a post-build step to copy it to the relevant place. 最后,根据其他人对您的问题的评论,如果您希望DLL同时出现在两个位置,则可以使用构建后步骤将其复制到相关位置。 To achieve this go to the project property pages under Configuration Properties -> Build Events -> Post-Build Event then enter the relevant command (the same as you would type at a command prompt) to do the copying eg copy myfile.dll .. , or as Alex Farber suggests, use VS macros to specify the locations in a more generalised way. 为此,请转到“ Configuration Properties -> Build Events -> Post-Build Event下的项目属性页面,然后输入相关命令(与在命令提示符下键入的命令相同)进行复制,例如, copy myfile.dll .. ,或正如Alex Farber建议的那样,使用VS宏以更通用的方式指定位置。 See this page for a list of available macros that you can insert into the command. 请参阅此页面以获取可以插入命令的可用宏的列表。 This should be considered a last resort solution for two reasons - (a) it is a hack, as you are redundantly copying a binary output to circumvent a shortcoming in your version controlling and/or build, when you should fix the problem at root, and (b) build events have a serious flaw in them in Visual Studio and that is that they don't allow values to be inherited. 出于以下两个原因,应将其视为万不得已的解决方案-(a)这是一种hack,因为当您应从根本上解决问题时,您正在冗余地复制二进制输出以规避版本控制和/或构建中的缺点, (b)构建事件在Visual Studio中有一个严重的缺陷,那就是它们不允许继承值。 This makes them a maintenance nightmare in bigger projects. 这使它们成为大型项目中的维护噩梦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的第一个 DLL 有很多编译错误我不明白 - My first DLL has many compile errors I don't understand 我在Visual Studio 2012 Pro中有一个C ++ DLL类型的项目,但无法将其编译为CLR-为什么? - I have a C++ DLL type project in Visual Studio 2012 Pro but I can't compile it as CLR - Why is that? Qt-Visual Studio 2013加载项不会编译项目 - Qt - Visual Studio 2013 Add-in won't compile the project 生成时,Visual Studio DLL项目不会创建.lib文件 - Visual Studio DLL Project Won't Create a .lib File When Building 我的 C++ 程序无法在 Visual Studio 代码上编译 - My C++ program won't compile on Visual Studio code 如果不使用引用,为什么不编译此代码? - Why won't this code compile if I don't use a reference? 我无法在 Visual Studio 2010 中编译 - I can't compile in Visual Studio 2010 但我不希望我的COM库有.lib或.exp文件! - But I don't want that .lib or .exp file for my COM library! Visual Studio 2015 可以编译和运行,但我在 Release/ 和 Debug/ 中都找不到 .exe - Visual Studio 2015 can compile and run but I can't find .exe in both Release/ and Debug/ 如何指定我希望我的 LIB 链接到的 DLL 文件? - 视觉工作室 2019 - How to specify the DLL file that I want my LIB to be linked to? - Visual Studio 2019
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM