locked
MPF Custom Project - Adding Custom Build Action RRS feed

  • Question

  • Hi,

     

    I’ve created a custom project using MPF in VS 2008 in c#. In my custom proj file, I’ve defined a custom BuildAction which I’m handling in my custom Targets file. I’ve also implemented the IWizard interface to handle setting my custom BuildAction for newly added items. All files added to my project will have this custom BuildAction specified. However, I’ve discovered that the BuildAction in the ProjectItem (passed in to ProjectItemFinishedGenerating method in my IWizard implementation) is not a string value, but a Microsoft.VisualStudio.Project.BuildAction. My question is, is there any way to extend BuildAction, or am I just stuck with the default values of Compile, Content, EmbeddedResource, & None? I’ve looked inside both the IronPython and the WiX Votive solutions and it looks like both of them get around this by overriding CoreCompile in the targets file. Any guidance on this is very appreciated. Maybe this is the way I should go? Here’s how I’m setting the BuildAction, which results in an ArgumentException.

     

    projectItem.Properties.Item("BuildAction").Value = "MyCompile"

    Wednesday, May 13, 2009 4:26 PM

Answers

  • I just discovered that the BuildAction enum is available in the MPF down in Microsoft.VisualStudio.Project in StructuresEnums.cs. For now, I've just added my BuildAction to this enum, which gives me what I want. I also added my BuildAction to TypeConverter.ConvertFrom and SR which makes this value appear in the BuildActions dropdown in the properties window. If there are problems with going this route, please somebody let me know. Thanks!

    • Marked as answer by Wesley Yao Wednesday, May 20, 2009 5:41 AM
    Wednesday, May 13, 2009 7:00 PM

All replies

  • I just discovered that the BuildAction enum is available in the MPF down in Microsoft.VisualStudio.Project in StructuresEnums.cs. For now, I've just added my BuildAction to this enum, which gives me what I want. I also added my BuildAction to TypeConverter.ConvertFrom and SR which makes this value appear in the BuildActions dropdown in the properties window. If there are problems with going this route, please somebody let me know. Thanks!

    • Marked as answer by Wesley Yao Wednesday, May 20, 2009 5:41 AM
    Wednesday, May 13, 2009 7:00 PM
  • Hi, caribou

    Your way should work fine with MPF, but for those using a Flavored Project, there might be some issues.

    I have provided an alternative way that can work for both MPF and Flavored Projects that requires no source code changing.

    See here: http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/bd74f1bc-2c60-4f9c-b29f-e50bf16aadfc/

    Best,
    Paul Reisert

    • Proposed as answer by Paul Reisert Thursday, June 25, 2009 11:40 PM
    Thursday, June 25, 2009 11:40 PM