Visual Studio 2010 isn't building before a run when there are code changes

Visual StudioVisual Studio-2010BuildDebugging

Visual Studio Problem Overview


I've been using using F5 (Start Debugging) for years to build the code (if its out of date), and then debug. This was working on VS 2010 also, however today it just start debugging without a build. Say I do a clean on the project, and then hit F5 instead of building it so it can run it throws an error message saying that the exe doesn't exist to run. How do I make it build first? What could have changed?

Visual Studio Solutions


Solution 1 - Visual Studio

Tools + Options, Projects and Solutions, Build and Run. "On Run, when projects are out of date" = Always build. The one below that = Do not launch.

Solution 2 - Visual Studio

I had this problem and it turned out to be the Configuration Manager. I had recently changed from Debug|Mixed CPU to Debug|Any CPU and the project wasn't set to build under this configuration

Solution 3 - Visual Studio

open your configuration manager and check out if the checkbox in the build column for your startup project is checked. I had the same problem, but the checkbox wasn't active, so i checked it and now it works!

Solution 4 - Visual Studio

Apart from the above also make sure that 'Only build startup projects and dependencies on run' is unchecked (in Tools-->Options-->Projects and Solutions-->Build and Run)

Solution 5 - Visual Studio

I had this problem too. I checked everything suggested to no avail. It turns out my clock on my pc had gotten set forward by about 12 hours, and I was saving to a network drive. The timestamps of the files were out of wack, and VS didn't think it needed to build my project because the files were super up to date.

Solution 6 - Visual Studio

For a while now I have alwasy been confused as to why my laptop (dual core 2ghz, 2Gb ram) compiled my website quicker than my desktop (quad core 3ghz with 16Gb ram). Both have SSD disks. Build options all set correctly (the same, core count = parallel builds) yet the laptop runs the site in a few seconds and the dekstop runs the site in about 30 seconds.

Found an additional option under the "Property pages" of the site, under the Build setting, laptop was set to "No Build" and desktop set to "Build and Run". Only found it after the site ran on the laptop without checking for a compiler error.

Might help someone in the future so thought I would add it to this post

Solution 7 - Visual Studio

Another Point to Check is under solution Property Page -->Configuration Properties --> configuration: make sure all checkboxes under Build Column is check for the project you need to be re-complied.

Solution 8 - Visual Studio

I tried the previous solutions with mixed results. BUT it seems to work for me whenever I go to Build -> Clean Solution

But it's getting annoying having to do that every single time.

Solution 9 - Visual Studio

For me it was happening because of build configuration settings. My visual studio solution has a number of projects which are a mix of C# and C++ projects. Now I realized that for some weird reason, Visual Studio prefers not to build C++ projects by default which is evident by build configuration settings. I noticed it just after adding a new C++ project into the solution. I don't know why VS doesn't follow same approach while adding a new C# project into the solution.

Right click solution file in solution explorer -> Click properties in context menu -> Select Configuration Properties node in left pane -> Select Configuration node. It shows the list of all the projects in the solution. The first project LearnDs is a C++ project. Notice the check box in build column in first row. It is unchecked. This was the reason why Visual Studio 2010 wasn't building my C++ project (on pressing F5) which contained some changes since it was last built successfully.

enter image description here

The moment I checked the corresponding checkbox and saved the build configuration settings for the solution, it worked. Now I see below prompt whenever I press F5 as VS is able to detect that there are some new changes since it was last built. This prompt is because my settings in Tools menu -> Options submenu -> Projects and Solutions node -> Build and Run Node -> "On Run, when projects are out of date" is set to Prompt to build. In case you don't like this prompt then set it to Always build.

enter image description here

Solution 10 - Visual Studio

Tool --> Options --> Project and Solutions.

  1. Set as Always build / Prompt to Build for "On Run, The project is out of date"
  2. Uncheck the check box for "Only build startup projects and dependencies on Run"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjamoneView Question on Stackoverflow
Solution 1 - Visual StudioHans PassantView Answer on Stackoverflow
Solution 2 - Visual StudioTimView Answer on Stackoverflow
Solution 3 - Visual StudioMichael ScherfView Answer on Stackoverflow
Solution 4 - Visual StudioAloView Answer on Stackoverflow
Solution 5 - Visual StudioVinnieView Answer on Stackoverflow
Solution 6 - Visual StudioJeggsView Answer on Stackoverflow
Solution 7 - Visual StudioDaniel NguyenView Answer on Stackoverflow
Solution 8 - Visual Studiouser2813625View Answer on Stackoverflow
Solution 9 - Visual StudioRBTView Answer on Stackoverflow
Solution 10 - Visual StudioPoovizhiView Answer on Stackoverflow