locked
How to include the ".props" file along with the ".targets" file programmatically? RRS feed

  • Question

  • Hello!

    I'm writing a custom app wizard in C# that creates new C++ projects. Since in VS2010 C++ projects also use MSBuild, I have to add custom build rules to the new project as a pair of  .targets and .props files. However if I do something like this:

     

    VCProject vcProj;
    VCProjectEngine vcEngine;
    vcProj.AddToolFile(vcEngine.LoadToolFile("foo.targets"));
    

    it inserts the foo.targets file into the project as it should, but it doesn't insert the foo.props file, even if it's there right beside the .targets file. Now, if I insert foo.props as a property sheet it kinda works, but  it inserts the .props file under 

    <ImportGroup Label="PropertySheets">
    

    in the project file and not under

    <ImportGroup Label="ExtensionSettings">
    

    as it supposed to (like if I add the targets file via the Build customization... menu item). It's ugly because that way the .props file shows up in the property manager, and not in the Build customization dialog.

    lt would be nice if it would be a way of adding the props file exactly like if it had been added by the IDE. 

    Is it possible? How?

     

    Thanks:

    Istvan

     

    PS.: If you want to move this to offtopic, please specify where I should ask this question then. Thanks again.

     

    Monday, May 10, 2010 4:41 PM

All replies

  • When you pass full path to the .targets file then both .targets and .props files are added. However, if you try to reference .targets file by custom msbuild variable (like $(CustomMsBuildVariable)\foo.targets) then only .targets file is added. Looks like VS2010 bug to me.
    Sunday, August 22, 2010 8:56 PM