Freigeben über


VS always thinks my project is out of date!

Has this happened to you?  You've built and run your Visual C++ solution, and without touching a thing you still get a dialog like the following whenever you re-launch it:

         

Out of date???  How can that be?

I ran into this for two separate reasons when creating a Visual Studio 2005 solution for Internet Hearts.  (More on this in the near future.)  But both times, it involved using MIDL in a Visual C++ project.

Reason #1:
I did something dumb.  I wanted to customize the location of the header file produced by MIDL, so under the project's properties I went to Configuration Properties -> MIDL -> Command Line and under Additional options put /h ..\foo\bar.h.  But the project already has a built-in setting for that header file, and was already putting a /h bar.h before mine.  My own /h won, so MIDL put the header file where I wanted it and I didn't notice the duplicate entry.  However, that's why VS always thought my project was out of date: it never saw the header file that it was expecting, and assumed that rebuilding the project would put it there!

Instead of messing with the raw command line, I should have set Header File to my desired value under Configuration Properties -> MIDL -> Output.  The reason I say my actions were dumb is that I even got a warning about the situation:

command line warning MIDL1007 : switch specified more than once on command line : header

But to be fair, this got lost in a sea of warnings that I still needed to deal with.  (More on this another time, too.)

Reason #2:
I don't feel as bad about this one, because it happened without changing any project settings, and there was no warning.  By default, a project's MIDL settings have Generate Type Library (under Configuration Properties -> MIDL -> Output) set to Yes.  This means that the issued MIDL command contains /tlb XXX.tlb.  But the IDL file in my project had no library statement in it; it was just a handful of interfaces.  So VS expected a TLB to be present, despite the fact that there was no way one could ever get generated without changing the IDL!  I'm actually a little surprised that MIDL doesn't give a warning in this situation.

Hopefully these experiences will help someone who stumbles across this.  The dialog above certainly has room for improvement.  It would be nice to drill into which files are out of date.  Also, what happens after you select "Do not show this dialog again"?  Next time, will it build the out-of-date projects or won't it?  I'm afraid to try because I don't want to lose the dialog! :)

Have you run into the "This project is out of date" pitfall before?  What was the cause?

P.S.  Josh is right!  I wish I could tag this post to be a part of an über VS tips category.

Comments