locked
How to Detect if Project is Up to Date or Not at Start of Build RRS feed

  • Question

  • Updated to Clarify

    When Visual Studio (VS) performs a build, it determines whether or not to build a project or state that a project is "Up to Date" based on whether the contents of any of the included project source files change since the last build.

    Is there a way for a VS extension to determine at the project build start event to determine if any of the files in the project are out of date since the last build and therefore VS needs to build the project or whether all the project files are the same and therefore there VS will not build the project, just state that it is up to date?

    I want to take an action at the project build start event only if the project will indeed be built.

    For completeness sake, here are the important build events:

    • Solution build start
    • Project build start
    • Project build end
    • Solution build end

    Thursday, February 26, 2015 5:33 PM

All replies

  • I want the ability to capture information at the start of a build process and then use that at the end to conditionally tell Visual Studio that no changes were made. I talk to a specific file.

    I'm sorry, but I don't understand what you mean.  Can you please elaborate?  Explain what you mean by: "capture information at the start of a build".  Do you mean like when code was fetched from a repository or something like that?  And can you explain what you mean by "conditionally tell Visual Studio that no changes were made."  What's wrong with Visual Studio's built-in mechanism in the case you're envisioning?

    Can you provide a little more detail about what you're trying to do?

    I know that Visual Studio uses more than just the contents and date/time stamp.

    Oh really?  I hope not!  That would seriously break what I understand about how Visual Studio works.

    As far as I know Visual Studio uses the modification date and time.  If the modification date and time are the same as before, then the file is not recompiled - even if the contents are different.  If the modification date or time are different then the file is recompiled - even if the contents are the same.  This is how "touch" works, FYI.

    Thursday, February 26, 2015 7:24 PM
  • I rewrote the question, so your comments do not really apply. I apologize for that, but I am trying to solve a problem, so hopefully this explanation is a bit better.
    Thursday, February 26, 2015 8:42 PM
  • Hi Sarah,

    I would let the MSBuild itself to determine if the project file need to perform a build, execute the command "Build.BuildSolution", and VS will do the rest.

    If you want to do it by yourself, you need a table to store the original modified time, and compare the latest modified time and the old one to determine if it's out of date.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 3, 2015 7:51 AM