Visual Studio: How to build only some projects

15,932

Solution 1

Creating a new configuration would be the best way to do it.

Alternately, create a second solution file and only add the projects you're interested in. We've done that for a few of our enterprise products where a full solution would load dozens of projects. The main reason we did this is to cut down on the resources that VS uses. Name the solution something like "My Product - minimal build". You have the option of checking it in or not.

Solution 2

Right-click on the Solution and choose "Configuration Manager". Un-check the "Build" columns for each one you don't want built.

Solution 3

Go to the solution explorer (CTRL+SHIFT+L for me), mark the projects you want to build, right-click them (SHIFT+F10 if you are a keyboard aficionado) and select "Build Selection"

Solution 4

Look into the solution explorer - right click the projects you don't want to build and unload them

Share:
15,932
Yaron Naveh
Author by

Yaron Naveh

Web Services Performance, Interoperability And Testing Blog - WCF, Axis2, WSIT... blog twitter

Updated on June 14, 2022

Comments

  • Yaron Naveh
    Yaron Naveh almost 2 years

    My VS solution has many projects. I am currently only working on some of them so I want CTRL+SHIFT+B to only build some. What's the best way to do it?

    I thought about creating a new configuration but I would need to check it in and it does not seem right. I don't care if it will be only a "local" setting on my machine.

  • Yaron Naveh
    Yaron Naveh over 14 years
    this would affect all users of this solution, I want to only affect me
  • Yaron Naveh
    Yaron Naveh over 14 years
    this would affect all users of this solution, I want to only affect me
  • Yaron Naveh
    Yaron Naveh over 14 years
    you're first suggestion (new configuration) would also appear on other users machines. Also if we have already 2 configs (debug & release) I would now need to have 4 (debug, release, my - debug, my - release). As for the second option, so it's like the new solution works on the actual projects "by reference" so changes are affected in both, and the only time I would need to use the original solution is if I have to do changes in the solution itself. Is this right?
  • sbi
    sbi over 14 years
    @Yaron: No, this wouldn't affect the solution at all, let alone other users of it. (It's a way to only build selected projects instead of the whole solution.)
  • nuiun
    nuiun over 14 years
    A solution file is essentially just a list of projects. Projects exist completely independent of a solution. You can add the same project to multiple solutions. If you have two solutions open that contain the same project, and you edit the project file in one window and switch over to the other window, Visual Studio will detect the changes and ask you if you want to update.
  • nuiun
    nuiun over 14 years
    So to answer your question specifically - yes, solution files simply reference a project. You could create a new solution file for yourself that had the build settings you wanted, and work with the same exact project files that everyone else was working with.
  • Kevin R.
    Kevin R. about 6 years
    Consider adding some documentation links. Also be aware this answer may be different depending on which version of VS is being used.
  • Himesh Sameera
    Himesh Sameera almost 6 years
    Worked for me on VS2015
  • Dave Cousineau
    Dave Cousineau over 5 years
    this works, but it would be nice to save that subset of projects somewhere and build with a single keypress or toolbar button, rather than search the whole solution explorer manually every time