4

Possible Duplicate:
Visual studio keeps building everything

I have a project that includes an idl file that generates a .c file that is included in another file of the same project.

I build this project and all is fine, I then try to run the project and I am told the project is out of date and would I like to build it. If I select yes to build it the idl is compiled again.

Is there any way of stopping this without setting the VS project setting to never prompt me for a build?

Community
  • 1
  • 1
  • What happens if you click the 'Compile **and** Run' button? Does the same thing happen? – Greg Treleaven Feb 20 '11 at 13:13
  • Hi Greg, by 'compile and run' button, do you mean the 'start debugging' (F5) command? - or is there another command you are referring to? If it is the F5 command then that is what I am using for debug build. I start without debugging on a release build (Ctrl + F5)- and the same happens where even though I know everything is built, I still get a message telling me I need to build the project. – Gary Miller Feb 21 '11 at 13:05
  • @Gary Miller Just out of interest, why do you want to keep the build-before-run dialog rather than building automatically? I am yet to come across a case where running your code without the most recent modifications is ever useful, so I'm interested to hear one. – Zooba Feb 22 '11 at 10:00
  • @Zooba our project is a very large one with multiple sub projects, making changes in a base project which is used by many of the other projects can result in a build time of a couple of minutes, we will quite often have salesmen come over to demo another aspect of the software to a customer so we may want to quickly run the last build showing a different feature that may have been implemented. An honest opinion by me would be we need to investigate the coupling between our projects. – Gary Miller Feb 22 '11 at 11:14
  • @Gary Miller That's a fair call. I've never been in a dev environment where sales will ask for a demo on a dev machine rather than a separate machine. – Zooba Feb 22 '11 at 20:34
  • *dusts off vague recollections of COM* sounds like a circular reference between the things dependent on the out but of the MIDL compiler. Does a clean build fail the first time you attempt it and then succeed the next time? (bear in mind that sometimes this gets masked if you are checking generated .h, .c. tlh, or thi files into source control. – dkackman Feb 22 '11 at 21:51

1 Answers1

2

Once you've built the .idl file once, open it's properties and enable "Exclude from Build".

If you update the file, you can build it manually by selecting the file in Solution Explorer and choosing "Compile" (the shortcut is Ctrl+F7 on my setup, but this may vary).

If you don't include the generated files in your version control system, a fresh checkout will also need to manually rebuild the .idl file. This case in particular can cause a lot of confusion - it may be worth including the generated files under version control.

Another option is to create a custom build tool (or pre-build event), which would compare the last modified date/time of the .idl file with the last modified date/time of the output files and then call MIDL if required. This is the behaviour that VS uses to determine whether or not to run CL, but it is not used for MIDL and, as far as I know, cannot be enabled in VC++ 2008 project files.

Zooba
  • 11,221
  • 3
  • 37
  • 40
  • An ideal world for us would be the IDL will generate the .c file only when it needs to - is there anyway of telling whether an IDL has already generated an up to date source file? – Gary Miller Feb 22 '11 at 11:29
  • @Gary Miller I agree, that would be ideal. The usual test done is to compare the last modified time of the source file to the last modified time of the output file. MIDL apparently doesn't do that. If you were using VS2010 it would be possible to modify the project file (an MSBuild script) to test this, but VS2008 used a different project file format that AFAIK doesn't support this kind of modification. A custom build tool may also work here, but distributing it to dev machines is 100% required and possibly unnecessary pain. – Zooba Feb 22 '11 at 20:28
  • 1
    I think I have spent enough time on this now - building the IDL then excluding it from the build will be my answer. Thanks for your time and input. – Gary Miller Feb 23 '11 at 07:58