locked
Adding build actions to a project for a file with a custom extension RRS feed

  • Question

  • I want to have vs set up some build actions in a C++ project when I add a file with a custom extension. For example, suppose I add the file Test.evt. I want to run a batch file on this to code generate .h and .rc files to be included in the project. The project file would include a section looking something like:

    <ItemGroup>
      <None Include="etw\Test\resources\MSG00001.bin">
        <DependentUpon>Test.evt</DependentUpon>
      </None>
      <None Include="etw\Test\resources\TestTEMP.BIN">
        <DependentUpon>Test.evt</DependentUpon>
      </None>
    
      <CustomBuild Include="Test.evt">
        <Command>copy %(Identity) %(Filename).h</Command>
        <Outputs>%(Filename).h;%(Outputs)</Outputs>
        <Command>buildevents.cmd  %(Identity)  %(Filename) %(RootDir)%(Directory)</Command>
      </CustomBuild>
    
      <ClInclude Include="Test.h">
        <DependentUpon>Test.xml</DependentUpon>
      </ClInclude>
    
      <ResourceCompile Include="etw\Test\resources\Test.rc">
        <DependentUpon>Test.xml</DependentUpon>
      </ResourceCompile>
    </ItemGroup>

    This is basically what happens in C# project when a .tt file is added.

    What is the recommended way to achieve this?

    Thanks

    Bill Hay

    Wednesday, October 10, 2012 3:05 PM

Answers