Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Visual Studio: Selectively Compile Files

📅 2011-May-09 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ visual studio ⬩ 📚 Archive


Sometimes after a successful build, you may feel the need to selectively compile a few files in the solution. This is especially needed with C++, where you might sometimes suspect linking problems or just want to look at the compile output. How to selectively compile a subset of the source files inside a solution?


The common way to do this is to selectively compile each of those files by choosing Compile or Ctrl+F7 for each of them. This is repetitive work and you also need to be present to Compile after each file.

Another trick is to go to each of these files and change a character in them and save the files. Visual Studio notices the changed files and will compile them if you Build or press F7 on the solution.

The best solution is to just go to each of these files and press Save or Ctrl+S. Visual Studio changes the modified timestamp of the files on this operation and will faithfully compile these files if you Build or press F7 on the solution.

Tried with: Visual Studio 2010