none
Is there a way to extend or create custom transforms? RRS feed

  • Question

  • I know that there is a way to add your own custom tasks to msbuild.

    Is there a way to create a custom transformation operator for metadata? 

    Here is my dilemma.  I am using the Sandcastle Help File Builder extensions (version 1.8) to generate my documentation in Team Build.  There is a problem with using a property to define the paths using property strings embedded in the DocumentSource sourceFile elements of the .shfbproj file.  Path values passed in using the embedded property strings cannot contain spaces, otherwise you get an error.  You can't " or singlequote the paths or you get another type of error.  I found that the only way to get it to accept the path is to substitute %20 for all spaces in the path string. 

    I have a nasty workaround that involves using the regex task to transform the Item containing the expanded property containing the path but that is very limiting. 

    It would be useful to have an inline transformation for the metadata that I could use to substitute the space characters directly. 
    Something with a general form like @(Itemspec->%(Replace("regularexpressiontofind","replacementstring",MetaDataSpec)))
    In my example I could use this like @(Path->%(Replace("\s","%25%32%30",%(Directory)))).

    I suspect transforms are bounded by the msbuild engine's parsing schema but if there were a way to extend that I could supply the custom transformation as needed.

    Richard

    Friday, April 3, 2009 2:22 PM

Answers

  • Hello Richard,

    Thanks for your posting on MSBuild forum.

    As per my understanding, item metadata assigned to an item collection to provide additional information for that item collection, and can be used by tasks that require more information about these items. Item metadata is declared in the project file by creating an element with the name of the metadata as a child element of the item. The Well-known Item Metadata is added automatically. Item transforms are not arbitrary, but are limited by special syntax in which all transform modifiers must be in the format %(ItemMetaDataName).

    I don't think you can do transformation like this with the current MSBuild, however, I am not sure if this is supported in the future. I will comfirm this with PG and will get back to you when I get response from them.

    My workaround for this is, like you said, we can create an custem task to do the transformation.

    Thanks,
    Rong-Chun Zhang

    Please mark the replies as answers if they help and unmark if they don't.
    Welcome to the All-In-One Code Framework, a sample code project owned by the MSDN Forum Support team!
    • Marked as answer by Richard Winks Wednesday, April 8, 2009 11:53 PM
    Wednesday, April 8, 2009 10:59 AM

All replies

  • Hello Richard,

    Thanks for your posting on MSBuild forum.

    As per my understanding, item metadata assigned to an item collection to provide additional information for that item collection, and can be used by tasks that require more information about these items. Item metadata is declared in the project file by creating an element with the name of the metadata as a child element of the item. The Well-known Item Metadata is added automatically. Item transforms are not arbitrary, but are limited by special syntax in which all transform modifiers must be in the format %(ItemMetaDataName).

    I don't think you can do transformation like this with the current MSBuild, however, I am not sure if this is supported in the future. I will comfirm this with PG and will get back to you when I get response from them.

    My workaround for this is, like you said, we can create an custem task to do the transformation.

    Thanks,
    Rong-Chun Zhang

    Please mark the replies as answers if they help and unmark if they don't.
    Welcome to the All-In-One Code Framework, a sample code project owned by the MSDN Forum Support team!
    • Marked as answer by Richard Winks Wednesday, April 8, 2009 11:53 PM
    Wednesday, April 8, 2009 10:59 AM
  • Thanks Rong-Chun Zhang.

    That is as I expected but it didn't hurt to ask.  Besides it may have planted a seed for expanding transformation features.

    Richard
    Wednesday, April 8, 2009 11:57 PM

  • Thanks for your feedback. PG has confirmed that it is not support in MSBuild 3.5 and they will consider supporting this feature in the future.

    Regards,
    Rong-Chun Zhang
    Please mark the replies as answers if they help and unmark if they don't.
    Welcome to the All-In-One Code Framework, a sample code project owned by the MSDN Forum Support team!
    Thursday, April 9, 2009 10:48 AM