locked
What am i missing with the transformations? RRS feed

  • Question

  • User-1668220527 posted

    Simple problem folks...  Have a web.config with keys as per:

        <add key="salesEmail" value="michael.macneil@elfab.com"/>
        <add key="verificationEmail" value="michael.macneil@elfab.com"/>

    When doing a release compile i want to swap them with the transformation in Web.Release.config:

      <appSettings>
        <add key="salesEmail" value="salescentral@elfab.com" xdt:Transform="SetAttributes" xdt:Locator="Match(salesEmail)"/>
        <add key="verificationEmail" value="deborah.bevan@elfab.com" xdt:Transform="SetAttributes" xdt:Locator="Match(verificationEmail)"/>
      </appSettings>


    However, when building using TFS it just gets ignored.  Have tried using Transform="Replace" but that gets ignored too.  Never successfully done this before so assume it is me not understanding this!

     



     

    Tuesday, August 20, 2013 11:27 AM

Answers

  • User-1668220527 posted

    Finally got this to work!!  First mistake was i need to Replace, not SetAttributes (makes sense!) 

    Indeed as CodeDog mentioned you are matching the string of text called 'key'...if you had an attribute called 'salesEmail' you would use Transform="SetAttribute" and xdt:Locator="Match(salesEmail)"

     

    <appSettings>
        <add key="salesEmail" value="michael.macneil@elfab.com" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
        <add key="verificationEmail" value="michael.macneil@elfab.com" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
      </appSettings>

    but the real key from the build perspective was that for TFS2012 you need to specify the build args when you queue the build (or add them to a build template):

    /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false /p:Configuration=Debug
    /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false /p:Configuration=Release


     One step closer to removing human error from our builds!! Cool


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 21, 2013 6:38 AM

All replies

  • User1937807931 posted

    Hello!

    I am pretty sure you need to use the 'key' word itself, and not the value of the key.  It would look something similar to the following;

      <appSettings>
        <add key="salesEmail" value="salescentral@elfab.com" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
        <add key="verificationEmail" value="deborah.bevan@elfab.com" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
      </appSettings>

    In short, that second transform is going to 'match' on a Key called "verificationEmail" in the main Web.Config and replace it's value with the one you use here (deborah.bevan@elfab.com).

    See if that works better for you.

    Tuesday, August 20, 2013 4:30 PM
  • User-1668220527 posted

    Hello!
    I am pretty sure you need to use the 'key' word itself, and not the value of the key.  It would look something similar to the following;
    <appSettings>
        <add key="salesEmail" value="salescentral@elfab.com" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
        <add key="verificationEmail" value="deborah.bevan@elfab.com" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
      </appSettings>

    In short, that second transform is going to 'match' on a Key called "verificationEmail" in the main Web.Config and replace it's value with the one you use here (deborah.bevan@elfab.com).

    See if that works better for you.

    Thanks CodeDog but tried that earlier and thought i was misunderstanding it!  I think there must be an extra step to get TFS to build it right, perhaps some argument to pass to the Builder.  Bit disappointing as the concept is great and it seems to be built into Visual Studio IDE but cannot get it to work!!Frown

    Wednesday, August 21, 2013 5:08 AM
  • User-1668220527 posted

    Finally got this to work!!  First mistake was i need to Replace, not SetAttributes (makes sense!) 

    Indeed as CodeDog mentioned you are matching the string of text called 'key'...if you had an attribute called 'salesEmail' you would use Transform="SetAttribute" and xdt:Locator="Match(salesEmail)"

     

    <appSettings>
        <add key="salesEmail" value="michael.macneil@elfab.com" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
        <add key="verificationEmail" value="michael.macneil@elfab.com" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
      </appSettings>

    but the real key from the build perspective was that for TFS2012 you need to specify the build args when you queue the build (or add them to a build template):

    /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false /p:Configuration=Debug
    /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false /p:Configuration=Release


     One step closer to removing human error from our builds!! Cool


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 21, 2013 6:38 AM
  • User1937807931 posted

    Good!  Tenacity is usually the underlying solution, huh!

    Wednesday, August 21, 2013 6:05 PM