Visual Studio: Difference between Build and Rebuild

Believe it or not, I was never sure about this until this morning when another dev and I were discussing it. So, I searched the web and found the answer:

Build means compile and link only the source files that have changed since the last build, while Rebuild means compile and link all source files regardless of whether they changed or not. Build is the normal thing to do and is faster. Sometimes the versions of project target components can get out of sync and rebuild is necessary to make the build successful. In practice, you never need to Clean.

Build or Rebuild Solution builds or rebuilds all projects in the your solution, while Build or Rebuild <project name> builds or rebuilds the StartUp project. To set the StartUp project, right click on the desired project name in the Solution Explorer tab and select Set as StartUp project. The project name now appears in bold.

Compile just compiles the source file currently being edited. Useful to quickly check for errors when the rest of your source files are in an incomplete state that would prevent a successful build of the entire project. Ctrl-F7 is the shortcut key for Compile. (I just used this today with DotNetNuke - apparently the devs left out a codebehind class file on the EditAddress ASCX control for the WebStore. I simply excluded the control and it all built just fine. I'll worry about the Address thingy later [it was in C# BTW]).

  • All source files that have changed are saved when you request a build/rebuild, so you don't have to save them first.
  • When you run your executable (F5 or Ctrl-F5), Visual Studio saves all your changed source files and builds anything that changed, so you don't need to explicitly do those steps every time. This allows for quick "trial and error" debugging.

Incidentally, if you like those little Visual Studio keyboard shortcuts, you can download posters of the C# and the VB.Net ones, respectively:




  1. Anonymous12:23 PM

    i love these little shortcuts, i didnt realise there was one for compiling current page.

    mind you, it was only a few months ago i doscovered the joys of shift-delete in VS :D

  2. Anonymous7:56 AM

    Hehe - funny thing; I've got so much respect and get so much motivation and learned so much from reading your posts, and then: Didn't he know this - haha ;-))

    A fine christmas to all of you!

  3. Yup! There is no shame in not knowing something that you probably should know. There is shame in pretending that you know and acting like a moron about it.

  4. Anonymous5:52 PM

    Glad I found this article. I just installed new VS8, and when I select Build, it always rebuilds all of my projects, even if nothing has changed. Anyone have any idea what to look at?? Same sln/projects do not do this running in .NET 2003.

  5. If you have projects in your solution that are pretty much "baked" and don't need to be rebuilt, set the Build action off in the Build configuration dialog for the solutio. You can set your solution to build only the projects in it that you want rebuilt.

  6. Anonymous9:39 AM

    It can also be done at the VS level:

    Tools -> Options -> Project and Solutions -> Build and Run -> select 'Only build startup projects and dependancies on run'


  7. Love it. Especially then bit about "Compile just compiles the source file currently being edited. ... Ctrl-F7 is the shortcut key for Compile."


Post a Comment

Popular posts from this blog

ASP.NET: Loss of Session / Cookies with Frames

How to use Word and Excel in ASP.NET: Don't!