How to prevent VSCommunity 2019 from rebuilding a file when it wasn't modified

Igor Zachcial 1 Reputation point
2021-04-07T14:41:31.883+00:00

Hello Everyone,

I am currently working on a C++ project, and I encounter the following problem.

When I open a file (any file) or put my cursor in a currently opened file, even if I do not make any operation and have built the solution moments ago, when building the solution again (using build, not rebuild), the said file is recompiled which leads all dependent files to be recompiled as well.

I set the MSBuild project build output verbosity in Options->Projects and Solutions->Build And Run to Diagnostic, and it in fact shows the file as having been modified at the time I opened it.

This is quite problematic, since the codebase is becoming increasingly large, so opening any file deep down the dependency chain makes most of the application to be built again on launch, even if no modifications were made at all.

My setup is as follows:

OS Name: Microsoft Windows 10 Professionnal
Version: 10.0.19041 Build 19041
IDE: Visual Studio Community 2019 16.9.3

The project is a CMake generated project using CMake version 3.17.3

I'm becoming quite desperate regarding this issue, and cannot find any solutions to this.

Any help is appreciated, thank you all in advance

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,565 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,513 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,782 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Anna Xiu-MSFT 25,376 Reputation points Microsoft Vendor
    2021-04-08T09:16:26.373+00:00

    Hi @lgorZachcial-8297,

    Welcome to Microsoft Q&A!

    Please create new projects to check if the situation occurs in all projects or not.

    Then, please make sure that the tools > Options > Project and Solutions > Build and Run > “build startup projects and dependencies on Run” is checked. And delete the hidden .vs, bin and obj folders in the project folder.
    After that, run the command: devenv /safemode to launch your VS without any extensions, check if the installed extensions affect or not.

    Sincerely,
    Anna

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    0 comments No comments

  2. simonx 126 Reputation points
    2021-04-08T09:44:15.757+00:00

    This sounds very similar to a problem that I have had for some time now with Visual Studio 2019, building a project in Visual C++. I reported this in the old Visual C++ forum: "Lot of Unnecessary Visual Studio Rebuilds - Tracking Log problem?"- lot-of-unnecessary-visual-studio-rebuilds-tracking-log-problem

    I was asked to build a very small project that exemplified the problem which I was not able to do. It seemed to me to be related somehow to the size of the project (mine is very big). At any rate, I could never get it to happen with small projects. So I never got anywhere with it. But it has had a very bad effect on my productivity.

    In my case, I can't say that I noticed that it had anything to do with clicking on files without editing them. A fairly typical scenario is that I only have 3 .cpp files open and no .h or .inl files open. I do a build. I make a change to one of the 3 .cpp files, and this triggers a massive rebuild. Sometimes it seems to happen even if I haven't changed anything. But it's not consistent and I have not been able to spot a pattern. But like IgorZachcial-8297, I consider this to be a major problem because it dramatically reduces my productivity. A complete rebuild can take about 20 minutes.

    0 comments No comments

  3. simonx 126 Reputation points
    2021-04-08T09:58:27.177+00:00

    For interest, other people have also reported rebuild problems with Visual Studio. I'm not sure if they're related or not. See "Visual Studio always rebuilding projects and message is "will be compiled because the tracking log is not available" when source folder enlisted in git under Windows Subsystem for Linux (WSL)" - 292089

    0 comments No comments