简体   繁体   中英

Visual Studio 2012 not building dependent projects

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:

  • Library A
  • ConsoleApp 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.

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.

Could I have something configured incorrectly? Or is this a bug in VS2012?

Your symptoms sound very similar to those I experienced a while ago . Ensure that the projects are set to build with your current active solution configuration and active solution platform under Build->Configuration Manager .

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.

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.

Try by removing project references and 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.

I tried all the solutions above and that did not fix the issue for me. I found that it was because of the Active configuration in the ConfigurationManager was set to build only the Main (start up) project.

Go to 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 here and this is the details on MSDN . Although it was weired, bcoz I never changed these settings and it was working properly last week 在此处输入图片说明

I've encountered a similar problem, the solution (or the probelem) were the Build and Run settings under Tools > Options... > Projects and Solutions > Build and Run where "Only build startup projects and dependencies on Run" was checked. The screenshot shows my currently working solution.

Visual Studio 2012选项

For me, I resolve the issue by right clicking on the project; Build Dependencies > Project Dependencies. Then manually setting the order for each project. very painful if you have a lot of projects.

在此处输入图片说明

确保引用项目具有与引用项目相同或更高的.Net框架版本。

在解决方案资源管理器中右键单击解决方案,然后单击“清理解决方案”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM