views:

215

answers:

1

Hi all, how do I check if a project is up-to-date?

I'm basically trying to programmatically build each project in a list but only if they have changed. So does anyone know of a way (using EnvDTE maybe) to check if a project changed and therefore needs to compile?

Thanks in advance for all the help.

A: 

Use the EnvDTE.Document interface:

Document d = //get document
bool saved = d.Saved;

The Saved property will be false if the document is dirty.

Dave Swersky
Ok .. So I have to iterate through the entire list of source code files in the project and check for d.Saved then right? That sounds like a good suggestion but do you know of doing that on the Project level without iterating through the list? Thanks
No, you'd only have to iterate through open windows... if you close a window after editing you are prompted to save or discard the changes so a closed window can't be dirty. EnvDTE.Windows will give you a collection of all open windows.
Dave Swersky
I just thought of a scenario where relying on the d.Saved method to determine if a project is out-of-date or not will fail. If I have a x.vb class and I make changes to it. Then hit save but not build the project right there, then this method would fail because d.Saved will return True (but the project is in dirty mode). I'm basically looking for the exact method the Visual Studio IDE uses to determine whether to compile the project or just return up-to-date check. Thanks