Visual Studio don't detect new change in code

Maxime Charriere 11 Reputation points
2022-06-02T14:21:00.813+00:00

In the Hello world C++ default project, when I modify the code I need to rebuild the entire solution after modifications. Visual Studio think that my code is already up-to-date.
It's not viable to rebuild because it take a lot more time in bigger project than rebuilding only modified targets.

MRE:

  1. File > New > Project
  2. Choose the C++ Console App (Prints "Hello world" by default)
  3. Build solution -> 1 build succeeded
  4. Modify code
  5. Build solution -> 1 up-to-date

Microsoft Visual Studio Enterprise 2022 Version 17.2.3

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,429 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,852 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Michael Taylor 56,946 Reputation points
    2022-06-02T14:51:39.767+00:00

    Sounds like the issue is that the files aren't being seen as changed on disk. If you save the file first does it work?

    First question is if you actually have the solution open and not just loaded into VS (there is a difference). Solution Explorer should show the solution node with the C++ project under it. There should be no mention of a "folder view".

    Is the file you're editing actually in the project? In the editor tab for the file you're modifying right click and select the option to open in file explorer. Is that the file the same file that is in the project under Solution Explorer?

    In Solution Explorer there is an option to show all files, not just those in the project. Next to the filename you should see C++ or similar. If you see a red icon then that file isn't part of the project.

    Is the project either the startup project or referenced by the startup project? If not then by default VS won't rebuild projects it doesn't need.

    If none of that helps then turn on detailed logging under Tools\Options -> Projects and Solutions -> Build and Run. Set the build output to Detailed and build the solution so we can see the build logs.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.