question

IgorZachcial-8297 avatar image
0 Votes"
IgorZachcial-8297 asked juhapartanen-5030 commented

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

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

c++vs-generalvs-msbuild
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I don't have this issue ... build report says project is up-to-date and does nothing more.
VSC2019 16.6.2 here.

0 Votes 0 ·
AnnaXiu-MSFT avatar image
0 Votes"
AnnaXiu-MSFT answered

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.







5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

simonx-0248 avatar image
0 Votes"
simonx-0248 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

simonx-0248 avatar image
0 Votes"
simonx-0248 answered simonx-0248 edited

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.