C# Visual Studio 2012 不构建依赖项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11064345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio 2012 not building dependent projects
提问by user1438940
I just upgraded a VS2010 project to VS2012 and am now having a problem where dependent projects are not building on demand. For instance, say I have the following projects in my solution:
我刚刚将 VS2010 项目升级到 VS2012,现在遇到了一个问题,即依赖项目没有按需构建。例如,假设我的解决方案中有以下项目:
- Library A
- ConsoleApp 1
- 图书馆A
- 控制台应用程序 1
Where ConsoleApp 1 references Library A. If I change the signature of a method in a class in Library A and run ConsoleApp 1, there will be a compiler error due to ConsoleApp 1 not seeing my changes because running ConsoleApp 1 did NOT cause Library A to build.
其中 ConsoleApp 1 引用库 A。如果我更改库 A 中某个类中的方法签名并运行 ConsoleApp 1,则会出现编译器错误,因为 ConsoleApp 1 没有看到我的更改,因为运行 ConsoleApp 1 不会导致库 A建造。
If I manually build Library A, then manually build ConsoleApp 1, it works fine. However, I would expect that running ConsoleApp 1 should cause any dependent projects to be rebuilt before launching.
如果我手动构建库 A,然后手动构建 ConsoleApp 1,它工作正常。但是,我希望运行 ConsoleApp 1 应该会导致在启动之前重建任何依赖项目。
Could I have something configured incorrectly? Or is this a bug in VS2012?
我可能配置不正确吗?或者这是VS2012中的错误?
采纳答案by user1438940
Try by removing project referencesand adding them again (path to follow: References ->(right click) Add reference -> Solution -> Project). Before giving another try Save All. This is how I solved it.
尝试删除项目references并再次添加它们(要遵循的路径:(References ->右键单击)Add reference -> Solution -> Project)。在再次尝试之前Save All。我就是这样解决的。
回答by spender
Your symptoms sound very similar to those I experienced a while ago. Ensure that the projects are set to build with your current activesolution configurationand active solution platform under Build->Configuration Manager.
你的症状听起来和我前段时间经历的非常相似。确保项目设置为使用您当前的active解决方案configuration和活动解决方案平台在Build->Configuration Manager.
回答by Clay Fowler
This happens when the .suo file for the solution becomes locked and Visual Studio is no longer able to write to it. Another symptom of this problem is that you will see temp suo files being created next to the solution when you open it. Try closing Visual Studio and deleting all *.suo files in your working area. Then reopen Visual Studio and rebuild all. No need to manually rebuild your solution. This will fix the issue when it is caused by a locked .suo, as happened to a colleague of mine today.
当解决方案的 .suo 文件被锁定并且 Visual Studio 无法再写入时,就会发生这种情况。此问题的另一个症状是,当您打开解决方案时,您会看到它旁边正在创建临时 suo 文件。尝试关闭 Visual Studio 并删除工作区中的所有 *.suo 文件。然后重新打开 Visual Studio 并重建所有内容。无需手动重建您的解决方案。这将解决由锁定的 .suo 引起的问题,就像我今天的一位同事发生的那样。
In his case, the cause seemed to be that he shutdown his laptop while Visual Studio was still open. Maybe the shutdown of Windows didn't complete cleanly? We can only speculate on how the .suo originally became locked.
在他的案例中,原因似乎是他在 Visual Studio 仍然打开时关闭了他的笔记本电脑。也许 Windows 的关闭没有完全完成?我们只能推测 .suo 最初是如何被锁定的。
回答by Has AlTaiar
I tried all the solutions above and that did not fix the issue for me. I found that it was because of the Active configurationin the ConfigurationManagerwas set to build only the Main (start up) project.
我尝试了上述所有解决方案,但并没有解决我的问题。我发现,这是因为Active configuration在ConfigurationManager被设定为只建主(启动)项目。
Go to Build> ConfigurationManager
前往Build>ConfigurationManager
Ensure that all the projects you want to build are checked as in the screenshot below
This is a similar issue on Asp.Net forum hereand this is the details on MSDN. Although it was weired, bcoz I never changed these settings and it was working properly last week

确保所有要构建的项目进行检查,如下面的截图这是Asp.Net论坛类似的问题在这里,这是在细节上MSDN。虽然很奇怪,但我从未更改过这些设置,上周它运行正常

回答by Korexio
I've encountered a similar problem, the solution (or the probelem) were the Build and Runsettings under Tools > Options... > Projects and Solutions > Build and Runwhere "Only build startup projects and dependencies on Run" was checked. The screenshot shows my currently working solution.
我遇到过类似的问题,解决方案(或problem)是在“仅构建启动项目和运行依赖项”Build and Run下的设置Tools > Options... > Projects and Solutions > Build and Run被选中。屏幕截图显示了我当前的工作解决方案。


回答by lorengphd
Right Click solution in solution explorer then click "Clean Solution".
右键单击解决方案资源管理器中的解决方案,然后单击“清洁解决方案”。
回答by vinu
make sure that the referencing project has same or higher .Net framework version than the referenced project.
确保引用项目具有与引用项目相同或更高的 .Net 框架版本。

