"Excluded from build" not working in visual studio

367 Views Asked by At

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

2

There are 2 best solutions below

0
On BEST ANSWER

I am dumb... In properties window I was configuring for Release and building in debug mode.

3
On

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.