1

I am using Visual studio 2019 professional. I created one solution in which all of my source files have main function. so whenever I want to run my specific program I exclude all other source files(containing main) from build and building. But recently exclude from build is not working properlyexclude from build-1

in above image you can see "MakeFunction.cpp" is excluded from build but not getting excluded. exclude from build-2

In this image you can see "InlineFunction.cpp" function is excluded in solution explorer window, but included

amutamil
  • 35
  • 4

1 Answers1

1

Visual Studio caches information about the solution. Sometimes the cache can become out of sync and/or corrupt.

Try restarting Visual Studio and reloading the solution.

If that doesn't help, try deleting the on-disk cache.

  1. Close Visual Studio so that the files are not in use.
  2. In the solution's directory, delete the .vs directory if it exists.
  3. In the solution's directory, delete any *.suo files. (.suo is "solution user options".)
  4. Restart Visual Studio and re-open the solution. Visual Studio will create new on-disk cache files.

You probably know that your approach is unorthodox and you might want to re-consider creating separate projects for each main and creating a shared static library or DLL project for the source files used in multiple projects. You would not be constantly changing your project files and you could build all your programs by building the solution.

Jonathan Dodds
  • 2,654
  • 1
  • 10
  • 14
  • I followed the steps you mentioned, as you mentioned it deleted the cache, so when I reopened the solution all file icon were showing that they are include but then I tried to exclude and same problem. Even I created another new solution/project and created one CPP file and tried to exclude, same problem persists. – amutamil Mar 31 '23 at 01:42
  • I was hoping it was just a cache issue. – Jonathan Dodds Mar 31 '23 at 11:58
  • 1
    no prob. other my company projects also not building or cleaning properly, so I totally repaired my VS with VS installer. it resolved the issue. – amutamil Mar 31 '23 at 16:06