locked
Forcing config transform on TFS Build RRS feed

  • Question

  • I have a web application project that uses a number of externally referenced config files.  The web.config imports a section from an external config file (AppSettings.config, ConnectionStrings.config, etc).  I use slow cheetah to generate the config transforms.  We have an automated deployment process using internal powershell scripts.  We cannot use web deploy.  How can I get the config transforms deployed to the _PublishedWebsites folder of the TFS drop location?  The config transforms work fine when publishing from VS 2012.  I've tried added properties to the msbuild parameters like TransformConfigFiles=True and DeployOnBuild=true.  The only potential solution I found was http://kjdaly.com/Blog/Details/5.  However, I don't want to specify every config file to transform.  I just want to rip through all configs and apply the transforms automatically.  Seems like a simple request but I can't find any documentation.
    • Edited by Shawn Brandt Wednesday, September 11, 2013 4:01 PM
    Wednesday, September 11, 2013 3:51 PM

Answers

  • Hi Shawn,

    Thanks for your reply.

    After Team Build, the _PublishedWebsites folder be created under Binaries folder. If you want to copy files to _PublishedWebsites folder, I think you can use the InvokeProcess activity to copy files from source to destination, please refer to: http://www.ewaldhofman.nl/post/2010/04/28/Customize-Team-Build-2010-e28093-Part-3-Use-more-complex-arguments.aspx.        

    For more information about apply config transforms on __PublishedWebsites folder, I think you can contact MSBuild experts for the better response. 


    John Qiao [MSFT]
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, September 13, 2013 8:26 AM
    Moderator
  • I figured out a solution that works for me.  I created 3 publishing profiles for my app that drops the code to a staging location so it can be picked up by our deployment scripts.  The trouble I was having was getting all 3 publishing profiles to run each time I kick off a build.  I could get one of the publishing profiles to run but not the other 2. In my project file I had to specify the publishing profile to use for a given configuration.  Then in my build definition I specified to run all 3 configurations and the app was staged in all 3 locations properly. 

    Project File

      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
        <PublishProfile>Dev</PublishProfile>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|AnyCPU'">
        <PublishProfile>Test</PublishProfile>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Prod|AnyCPU'">
        <PublishProfile>Prod</PublishProfile>
      </PropertyGroup>

    Build Definition

    Configurations to Build: Any CPU|Dev,Any CPU|Test,Any CPU|Prod

    MSBuild Arguments: /p:DeployOnBuild=True /p:CreatePackageOnPublish=True



    Tuesday, September 17, 2013 1:33 PM

All replies

  • Can you try passing the 'configuration' as a parameter?

    msbuild.exe "FirstWebApplication.sln" /p:DeployOnBuild=true /p:PublishProfile=Publish_Test2 /p:VisualStudioVersion=11.0;Configuration=Release

    Please mark this as answer, if this helps.

    _Raj

    • Proposed as answer by Rajarajan.S Wednesday, December 3, 2014 4:27 PM
    • Unproposed as answer by Rajarajan.S Wednesday, December 3, 2014 4:28 PM
    Wednesday, September 11, 2013 4:53 PM
  • Hi Shawn, 

    Thanks for your post.

    How did you do the config transforms when build and deploy using VS 2012?


    John Qiao [MSFT]
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, September 12, 2013 2:27 AM
    Moderator
  • Maybe I should explain the problem first.  I'm trying to set up automated build/deploys using TFS 2012.  I'm required to execute some custom powershell scripts to move the code from a staging location to the target server(s).  I followed Raj's advice and created 3 publishing profiles (dev, test, prod).  I have a dev build definition the executes the dev publishing profile which move the code to a staging location with the proper config transforms.  The powershell scripts then picks up the code from this location and deploys it.  This works well.  What I'm struggling with now is how do I handle promoting the code to the next environment.  I would like to take a specified build from dev and promote it to test but I also need the config transforms applied.  How would I accomplish that?
    Thursday, September 12, 2013 1:01 PM
  • Hi Shawn,

    ALM Rangers have come up with a new tool called Devops Workbench Express Edition Beta, which is used to build once, deploy multiple targets.

    http://blogs.msdn.com/b/willy-peter_schaub/archive/2013/09/10/alm-rangers-devops-workbench-express-edition-beta-is-available.aspx

    You can explore abt this.

    _Raj

    Thursday, September 12, 2013 3:40 PM
  • Looks like a phenomenal tool but it won't be something I'm able to implement in the short term.  Ultimately, I have a build that I would like to kick off a generate the output (with configs transformed) for our various environments (dev, test, prod).  In my build configuration I have it set to build all 3 configurations so if the build is determined to be successful it can be deployed up the stack.  I just want to get the config transforms applied to the _PublishedWebsites folder and I'm not have any luck.  The PublishProfile option doesn't work well because I have 3 configurations that I need to build and can only configure 1 PublishProfile to be used for a give build. 

    The strange thing is the config transforms are applied to the parent folder of _PublishedWebsites. 

    • Edited by Shawn Brandt Thursday, September 12, 2013 7:39 PM
    Thursday, September 12, 2013 7:38 PM
  • Hi Shawn,

    Thanks for your reply.

    After Team Build, the _PublishedWebsites folder be created under Binaries folder. If you want to copy files to _PublishedWebsites folder, I think you can use the InvokeProcess activity to copy files from source to destination, please refer to: http://www.ewaldhofman.nl/post/2010/04/28/Customize-Team-Build-2010-e28093-Part-3-Use-more-complex-arguments.aspx.        

    For more information about apply config transforms on __PublishedWebsites folder, I think you can contact MSBuild experts for the better response. 


    John Qiao [MSFT]
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, September 13, 2013 8:26 AM
    Moderator
  • I figured out a solution that works for me.  I created 3 publishing profiles for my app that drops the code to a staging location so it can be picked up by our deployment scripts.  The trouble I was having was getting all 3 publishing profiles to run each time I kick off a build.  I could get one of the publishing profiles to run but not the other 2. In my project file I had to specify the publishing profile to use for a given configuration.  Then in my build definition I specified to run all 3 configurations and the app was staged in all 3 locations properly. 

    Project File

      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
        <PublishProfile>Dev</PublishProfile>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|AnyCPU'">
        <PublishProfile>Test</PublishProfile>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Prod|AnyCPU'">
        <PublishProfile>Prod</PublishProfile>
      </PropertyGroup>

    Build Definition

    Configurations to Build: Any CPU|Dev,Any CPU|Test,Any CPU|Prod

    MSBuild Arguments: /p:DeployOnBuild=True /p:CreatePackageOnPublish=True



    Tuesday, September 17, 2013 1:33 PM