Visual Studio Rebuilds unmodified projects

前端 未结 17 1860
夕颜
夕颜 2020-12-04 08:49

So, as the title reads, I have a VS2010 solution with ~50 projects in it right now. If I make a change to a \"top level\" project that nothing references then VS still rebui

相关标签:
17条回答
  • 2020-12-04 09:01

    Another problem that frequently happens is when some item in your solution has a modified stamp that is in the future. This can happen if you set your clock forward, and then set your clock to the correct time. I had this happen while installing Linux.

    In this case you can recursively touch all the files using git bash (yes, in Windows):

    find . -exec touch {} \;
    
    0 讨论(0)
  • 2020-12-04 09:01

    In my case (mixed C#, C++/CLI and native C++ solution) , some C++ projects were being re-linked even if nothing had changed. I spent ages trying to work out what was happening. In the end I worked out from the "Command Line" option that the PDB output path (option /Fd) could not handle the folder setting $(IntDir). I removed that - an empty value will do the default correctly - and my issue went away.

    0 讨论(0)
  • 2020-12-04 09:03

    The MSBuild team is collecting documentation about investigating build incrementality issues here: https://github.com/Microsoft/MSBuild/wiki/Rebuilding%20when%20nothing%20changed

    0 讨论(0)
  • 2020-12-04 09:06

    This happens when a project has a file that doesn't really exist.
    The project can't determine if the file was changed (because it's not there) so it rebuilds.

    Simply look at all the files in the project, and search for the one that doesn't have an expandable arrow near it.

    0 讨论(0)
  • 2020-12-04 09:07

    Open Tools - Options, select Projects and Solutions - Build and Run in tree, then set "MSBuild project build output verbosity" to Diagnostic. This will output the reason for building a project, i.e.

    Project 'ReferencedProject' is not up to date. Project item 'c:\some.xml' has 'Copy to Output Directory' attribute set to 'Copy always'.

    or

    Project 'MyProject' is not up to date. Input file 'c:\ReferencedProject.dll' is modified after output file 'c:\MyProject.pdb'.

    In this case the fix is to copy some.xml only if newer.

    Pre and post build events can trigger build as well.

    0 讨论(0)
  • 2020-12-04 09:07

    I've finally found one more culprit that I had hard time finding by increasing the build log verbosity.

    In some cases, MSBuild looks for vc120.pdb in the output folder, and if this file doesn't exist, it will rebuild the entire project. This occurs even if you have disabled debug symbol generation.

    The workaround here is to enable debug symbols and let this file get generated, then disable the setting again without deleting the PDB file.

    0 讨论(0)
提交回复
热议问题