c++ - multiple build rules using vc2010 and msbuild -
i'm managing c++ project in vs2010 , want have .cpp files run through external tool before going c++ compiler. signs seem indicate possible. see, example, here.
since happen on multiple projects, makes sense put functionality in property sheet , importing property sheet everywhere. before touched property sheet, looked in entirety:
<?xml version="1.0" encoding="utf-8"?> <project defaulttargets="build" toolsversion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <propertygroup> <_projectfileversion>10.0.30319.1</_projectfileversion> <extensionstodeleteonclean>...</extensionstodeleteonclean> <custombuildbeforetargets>clcompile</custombuildbeforetargets> </propertygroup> <itemdefinitiongroup> <clcompile> <additionalincludedirectories>...</additionalincludedirectories> <forcedincludefiles>%(forcedincludefiles)</forcedincludefiles> </clcompile> <link> <additionaldependencies>...</additionaldependencies> </link> <outputs>...</outputs> </custombuildstep> </itemdefinitiongroup> </project> as per above linked document, have added following lines:
<project> <propertygroup> ... <custombuildbeforetargets>clcompile</custombuildbeforetargets> </propertygroup> ... <itemgroup> <custombuild include="*.cpp"> <message>running custom build step</message> <command>dummy</command> <outputs>dummy</outputs> </custombuild> </itemgroup> </project> this appears have no effect, , custom build tool never runs before clcompile. have tried various ways of moving things around , renaming tags (the xml editor complains custombuild isn't valid according schema, example), nothing works.
what doing wrong?
although old question, attempt answer it.
the include attribute expects find *.cpp files in project directory. if there no .cpp files in project directory, custombuild "task" never kick in.
what op have done was
<custombuild include="**\*.cpp"> <message>custombuild kicking in</message> <command>echo %(identity)</command> <outputs>dummy</outputs> </custombuild> instead of
<custombuild include="*.cpp"> ... and have performed custombuild action on .cpp files in subdirectories of project directory, , not .cpp files waiting compiled.
if .cpp files not availble under project directory (can happen when such project directory structure used) op must explicitly point right "root" directory.
Comments
Post a Comment