Why doesn't F5 rebuild project before execution in Visual Studio?
Asked Answered
P

6

78

If I press F5, my project runs but it doesn't "see" any of the changes that I made. I need to manually (re)build before pressing F5 for it to work.

It worked well previously. Any idea what I need to change?

Presentation answered 7/2, 2011 at 14:20 Comment(1)
Those who come here after trying Tools->Options settings, PLEASE CHECK franssu's ANSWER BELOW.Vyky
A
81

Is it possible that you've reconfigured your "Build and Run" settings to "Never build"?

To check, follow these steps:

  1. From the Visual Studio IDE, open the "Tools" menu, and click "Options".
  2. Expand the "Projects and Solutions" header on the left.
  3. Click the "Build and Run" item.
  4. In the combo box labeled "On Run, when projects are out of date", ensure that you have the "Always build" option selected.

   Selecting Always build in VS Options dialog

Atrocity answered 7/2, 2011 at 14:33 Comment(2)
It's also worth un-ticking "only build startup projects and dependencies on Run".Chronogram
Also see this answer #1335274Endblown
A
87

Also :

  • Right Click on the solution in the solution explorer.

  • Click on "Properties".

  • Navigate to configuration Properties -> Configuration on the left side of the window.

  • Make sur the "Build" checkbox is checked on the line of your project.

Altheta answered 23/3, 2011 at 8:13 Comment(2)
Same here. Even though I did both the solutions, this one made my project start building. Might be because I have two projects in my solution and the one I was trying to execute was the one that didn't have the build option enabled, so none got built.Feldman
This fixed my issue, always had to rebuild after making changes to a recently added startup project in a solution.Discuss
A
81

Is it possible that you've reconfigured your "Build and Run" settings to "Never build"?

To check, follow these steps:

  1. From the Visual Studio IDE, open the "Tools" menu, and click "Options".
  2. Expand the "Projects and Solutions" header on the left.
  3. Click the "Build and Run" item.
  4. In the combo box labeled "On Run, when projects are out of date", ensure that you have the "Always build" option selected.

   Selecting Always build in VS Options dialog

Atrocity answered 7/2, 2011 at 14:33 Comment(2)
It's also worth un-ticking "only build startup projects and dependencies on Run".Chronogram
Also see this answer #1335274Endblown
Z
6

Another reason (which I had) could be dependencies.

In Solution Explorer, right click the Startup Project - Build Dependencies - Project Dependencies.

If the project you are working on is not set as a dependency of the Startup project then it won't get Built when you F5 / run.

Zacek answered 2/10, 2017 at 11:38 Comment(0)
H
1

Ok, for some reason all of the above solutions do not work for me, so I made a Pre-Build event (Right click project -> Properties -> Build Events) where I delete the bin and obj folder before building.

Hornbeam answered 18/6, 2019 at 9:24 Comment(0)
U
0

I am new to C# and Visual Studio but i found that going to Build -> Clean Project also worked for me, if you have already tried to select "Always build" option and it didn't work.

Unscrew answered 14/2, 2020 at 4:3 Comment(0)
H
0

If you get here looking for a way to always force a build on run, even when the project is not "out of date" check the answer for this question: -

https://mcmap.net/q/266163/-force-visual-studio-to-rebuild-on-start-debugging

I have targets for running npm in my csproj. They build less files into css. That was being skipped when the projects was considered "up to date" and the answer for the linked question forced it to build every time you run the project.

Hydrastine answered 25/1 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.