How do I find files that are missing from visual studio projects?

Ian Ringrose picture Ian Ringrose · Sep 1, 2011 · Viewed 58.4k times · Source

Due to issues with merging etc, we have lots of project files that don’t contain all source code files that are within their folders.

Before I write a little tool, that checks that every *.cs file is included in a project file, I wish to make sure that no-body else has already done that before.

(We have close to 100 project files, and 1000s of C# files)

-------------------

Clearly the support that visual studio now has for using wildcards to include all “*.cs” files from a given directory in the project is the best solution to this problem. In that there is then no need to update project files when “.cs” files are added, renamed ete. However it is only in VS2017 that this become usable from the UI.

Answer

JohnD picture JohnD · Sep 1, 2011

With that number of files and projects, it sounds like you might want something more automated. However, there is a manual approach (not sure if you are already aware of it):

  1. Select the project in Solution Explorer pane
  2. Project menu -> Show all Files
  3. Under the project, files which are not part of the project will show up as "ghost" icons
  4. Select the file(s) you want and pick "Include In Project" from the context menu