简体   繁体   English

Visual Studio 2010 —选择的解决方案配置会影响批量生成的输出

[英]Visual Studio 2010 — selected Solution Configuration affecting Batch Build output

Summary 摘要

I'm having a very strange behavior with Visual Studio 2010, and I'm not sure if it is a bug or if there is some twisted logic to why it is behaving in this way. 我在Visual Studio 2010中有一个非常奇怪的行为,而且我不确定这是否是一个错误,或者是否有些扭曲的逻辑来解释为什么这样做。

The executive summary is that when I use Batch Build->Select All->Rebuild to build all the configurations for all my projects, VS2010 produces differing output binaries depending on what is the currently selected Solution Configuration. 执行摘要是,当我使用Batch Build-> Select All-> Rebuild为所有项目构建所有配置时,VS2010会根据当前选择的解决方案配置生成不同的输出二进制文件。 This is really annoying because some of the project outputs fail to run correctly (giving a "[Project name] has stopped working" error dialog on startup) depending on which Solution configuration was selected during the batch build . 这确实很烦人,因为某些项目输出无法正确运行(在启动时出现“ [项目名称]已停止工作”错误对话框), 这取决于在批处理构建期间选择了哪种解决方案配置

More details 更多细节

I have a Solution with 3 C# projects in it (1 .dll outputting project, referenced by the other 2 .exe outputting projects). 我有一个包含3个C#项目的解决方案(1个.dll输出项目,由其他2个.exe输出项目引用)。 Of the .exe outputting projects, Project A has Release and Debug Project configurations. 在.exe输出项目中, 项目A具有“ Release和“ Debug项目配置。 Project B has a Debug , Release-x86 , and Release-x64 configuration because it needs some different post-build scripts run to give it the correct version 3rd party libraries. 项目B具有DebugRelease-x86Release-x64配置,因为它需要运行一些不同的生成后脚本来为其提供正确的版本3rd Party库。

I have 4 Solution Configurations: Debug , Release , Release-x86 , and Release-x64 . 我有4个解决方案配置: DebugReleaseRelease-x86Release-x64 Release-x86 and -x64 are set to build only Project B. Release and Debug build Project A and the shared dll project. Release-x86-x64被设置为只建项目B ReleaseDebug建设项目A和共享的DLL项目。

If I select the Debug Solution configuration from the current configuration drop-down box, and the Batch Build all, then when I try to run the Release configuration of Project A it fails to run. 如果从当前配置下拉框中选择“ Debug解决方案”配置,然后选择“全部批量构建”,那么当我尝试运行Project A的“发布”配置时,它将无法运行。 If I select any other Solution configuration from the drop down, and then Batch Build all, then it runs successfully. 如果我从下拉列表中选择其他任何解决方案配置,然后全部批量构建,那么它将成功运行。 When I diff the produced .exe file, I can see that it is different between these two cases. 当我比较生成的.exe文件时,我发现这两种情况之间存在差异。

Question

Is this some known intended behavior of VS2010? 这是VS2010的某些已知预期行为吗? If so, can someone give a hint as to why this problem may be occurring and how I can fix it? 如果是这样,有人可以暗示为什么可能出现此问题以及如何解决该问题吗? Is this a bug in VS2010? 这是VS2010中的错误吗?

Follow-Up Clue? 后续线索? [Edit] [编辑]

Could this have something to do with how VS2010 handles "Project references"? 这与VS2010如何处理“项目引用”有关吗? As I mentioned, both .exe projects reference the dll Project, call it Project D . 如前所述,两个.exe项目均引用dll Project,将其称为Project D。 I added that reference (to Project A, say) by selecting Add Reference -> Project -> Project D. But of course the different configurations of Project A want to use different configurations versions of Project D. When I examine the Project A -> Project D reference under Properties, I see a Path field that is not editable. 我通过选择添加引用->项目->项目D将引用添加到了项目A。但是,当然,项目A的不同配置希望使用项目D的不同配置版本。当我检查项目A->在“属性”下的“项目D”引用中,我看到“路径”字段不可编辑。 Depending on which Solution configuration is selected, I either see ...\\Project D\\bin\\Release\\Project D.dll or ``...\\Project D\\bin\\Debug\\Project D.dll , and I don't see any way to control this so I guess VS2010 is trying to be smart about picking the details of Project configurations. 根据选择的解决方案配置,我看到的是...\\Project D\\bin\\Release\\Project D.dll``...\\Project D\\bin\\Debug\\Project D.dll ,但是我没有看到有任何方法可以控制它,所以我想VS2010会在选择项目配置的细节方面变得更加聪明。 But even more strangely, if I select Batch Build -> Select All -> Clean to remove all compiled files, than these reference paths change to ...\\obj\\... instead of ...\\bin\\... when I inspect them, and I can't seem to change them back except by removing and re-adding the project reference. 但是更奇怪的是,如果我选择Batch Build-> Select All-> Clean删除所有编译文件,则当这些引用路径更改为...\\obj\\...而不是...\\bin\\...时我检查了它们,除了删除并重新添加项目引用外,我似乎无法将它们改回来。

Follow-Up 2 [Edit2] 跟进2 [Edit2]

I lied a little bit earlier, I actually have 2 .dll projects (Projects D and E, say) where D references E through a project reference. 我稍早撒谎,实际上我有2个.dll项目(例如,项目D和E),其中D通过项目引用来引用E。

I'm pretty sure something broken or bizarre with Project References in VS2010 is the culprit, and think I have found the root cause of the selected-Solution-Configuration-dependent behavior, with the following steps 我很确定VS2010中的Project References中的某些损坏或怪异是罪魁祸首,并认为我已经找到了与所选解决方案配置有关的行为的根本原因,通过以下步骤

1) I Batch Build -> Select All -> Clean, to remove all previously compiled binaries. 1)我批构建->全选->清理,以删除所有以前编译的二进制文件。

2) I select a Debug Solution Configuration from the drop-down. 2)我从下拉菜单中选择一个调试解决方案配置。

3) I Batch Build -> Select Only Project A Release -> Rebuild. 3)我批量构建->仅选择Project A Release->重建。

By watching the Output window, I see that VS2010 knows that Project A depends on D, and D depends on E, so it attempts to build them in reverse order. 通过查看“输出”窗口,我看到VS2010知道Project A依赖于D,D依赖于E,因此它尝试以相反的顺序构建它们。 It successfully builds the Release configuration of project E. But then it tries and fails to build the Release configuration of project D, because it complains about missing the missing Debug version of E dll file. 它成功构建了项目E的Release配置。但是随后,它尝试构建项目D的Release配置失败,因为它抱怨缺少缺少的E dll文件的Debug版本。 And likewise A fails to build because of the absence of the Debug version of D. 同样,由于缺少D的Debug版本,A无法构建。

So it seems that the selection Solution Configuration is overriding the configuration of referenced projects in Project to Project references. 因此,似乎选择解决方案配置会覆盖“项目到项目”引用中引用项目的配置。

Is that supposed to be the case??? 应该是这样吗???

After some further searching, I've found that this is a known bug in VS2010, marked as "Wont Fix" by Microsoft. 经过进一步的搜索,我发现这是VS2010中的已知错误,被Microsoft标记为“ Wont Fix”。 Batch Build in VS2010 is simply broken. VS2010中的批处理构建已被破坏。 If you think that's as dumb as I do, go ahead and express yourself to them. 如果您认为这和我一样愚蠢,请继续向他们表达自己。

https://connect.microsoft.com/VisualStudio/feedback/details/556158/batch-build-links-to-wrong-referenced-projects https://connect.microsoft.com/VisualStudio/feedback/details/556158/batch-build-links-to-wrong-referenced-projects

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

相关问题 如何从visual studio 2013的输出窗口中显示“排除未选择构建此解决方案配置的项目”消息 - How to exclude “Project not selected to build for this solution configuration” message from displaying in output window in visual studio 2013 无法在Visual Studio 2010中为安装项目选择新的解决方案配置 - Unable to select new solution configuration for setup project in Visual Studio 2010 如何在独立的dll中构建visual studio 2010解决方案? - How to build a visual studio 2010 solution into a standalone dll? Visual Studio 2010:如何在解决方案中强制执行项目的构建顺序? - Visual Studio 2010: How to enforce build order of projects in a solution? 带有VS 2013解决方案的Visual Studio 2010 Build服务器 - Visual Studio 2010 Build server with VS 2013 Solution Visual Studio解决方案:获取与构建配置相关的项目 - Visual Studio Solution: Get projects related to a build configuration 未选择为此解决方案配置构建项目 - Project not selected to build for this solution configuration 将Visual Studio解决方案的构建顺序输出到文本文件 - Output Build Order of Visual Studio solution to a text file 在Visual Studio 2010中构建问题 - Build Issue in Visual Studio 2010 生成失败:Visual Studio 2010 - Build Failed: Visual studio 2010
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM