The Problem
- I have a bunch of custom files in a visual studio 2010 project.
- I need to run a tool on those custom files when they change.
- The tool generates .h files included by existing .cpp files.
- I would like the tool to run as part of the build process.
- It needs to run from within visual studio, but ideally could also run as part of an msbuild process.
Existing sub-standard solutions
On each file, every time I add it, I can go to the file settings, set the Item Type to Custom Build Tool, and then in the Custom Build Tool dialogue, set the command line parameters, set the (hardcoded) outputs, and set the (hardcoded) additional dependencies.
Obviously, this is a poor solution because it's a non-trivial and error-prone amount of work every time you add a new file of the custom type.
The desired solution
I set up visual studio that for whatever file of extension .foo, it runs tool bar.exe, when the .foo file changes, before it compiles the CPP code.
Things I have attempted
Based on this: http://msdn.microsoft.com/en-us/library/3e889s84(v=vs.100).aspx I attempted to set up a .targets and .xml file. However, I can't find out how to create a new Item Type such that it shows up in visual studio, nor can I figure out how to make it magically apply to every file of type .foo. On top of that, I haven't figured how where any of that links to anything that describes the act of calling my bar.exe tool.
I've attempted to search through all of visual studio's xml/targets files in order to track existing Item Types and determine how they are translated into actual build actions. It always ends at the wall of ItemType, where there's a bunch described in ProjectItemsSchema, but I can't find where they are implemented, or how I might implement them myself.
MSDN's documentation has been a complete failure, and I think I've read every single potentially related page ten times, to no avail.
In visual studio 2008, I had this kind of thing working with a .rules file that looked like this:
<?xml version="1.0" encoding="utf-8"?>
<VisualStudioToolFile
Name="Foo Build Rules"
Version="8.00"
>
<Rules>
<CustomBuildRule
Name="FooBuild"
DisplayName="FooGen"
CommandLine="..\..\tools\FooGen.exe [inputs]"
Outputs="$(InputName).h"
AdditionalDependencies="*.foo"
FileExtensions="*.foo"
ExecutionDescription="Generating Foos..."
>
<Properties>
</Properties>
</CustomBuildRule>
</Rules>
</VisualStudioToolFile>
Yet this functionality has been deprecated in 2010, and I have been unable to figure out how to replicate it with the new system.
Help?