locked
Web.configuration transforms in TFS Build

    Question

  • Hi All,

    I m working on a requirement where TFS Build should read Web.config and transform based on that. I have a web.config file structure like this  Web.Config

    Web.Debug.Config

    Web.Live.Config 

    Web.Release.Config created from configuration manager, interestingly when I publish with to a Filesystem using the configuration Live, it gets reflected in Web.Config of output dir. 

    If I perform the same in TFS Build by changing(inputing) configuration = Live in Process Tab, I see that its not getting reflected in Web.config file of TFS Drops folder.

    I tried many blogs like 

    http://www.ozkary.com/2014/07/tfs-build-webconfig-transformation.html

    http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspxhttp://stackoverflow.com/questions/16311981/tfs-2012-and-web-config-transforms

    https://nirajrules.wordpress.com/2011/07/04/integrating-web-config-transformations-with-tfs-build/

    http://www.andygeldman.com/index.php/2011/10/web-and-app-config-transformations-with-tfs-build/

    unfortunately nothing worked out. And also changed the MS Build args to 

    /p:CreatePackageOnPublish=true /p:DeployOnBuild=true. Can someone please help me ? Any inputs are much appreciated.

    Thanks,


    Abraham Dhanyaraj

    Thursday, March 12, 2015 12:03 PM

Answers

  • Hi Abraham,  

    Thanks for your post.

    What’s the version of your TFS and VS?

    How did specific your solution using Web.Live.Config file when you manually publish to a Filesystem?

    Have you added that MSBuild target in your CSPROJ file followed the example in first article? If yes, please manually execute MSBuild command within /p:IsTFSBuild=True argument to build your solution manually, then check the result. You need ensure MSBuild command line can build your solution as expect, then build your solution using TFS Build.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 13, 2015 2:54 AM
    Moderator
  • Hi John ,

    Thanks for your inputs. Worked after making this modification 

    Mod 1 : Added the below tags in .csproj 

                 <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
      <Target Name="AfterBuild" Condition="'$(IsTFSBuild)' != ''">
        <Message Text="'Message After Build: TFSBuild Status $(IsTFSBuild) - $(OutDir)\_PublishedWebsites\$(TargetName) '" />
        <TransformXml Condition="Exists('$(OutDir)\_PublishedWebsites\$(TargetName)')" Source="Web.config" Transform="Web.$(Configuration).config" Destination="$(OutDir)\_PublishedWebsites\$(TargetName)\Web.config" />
      </Target>

    Mod 2 : Build manuall using msbuild D:\ADEC\Demo12\Demo12\Demo12.csproj /p:Configuration=myconfigfilesname /p:IsTFSBuild=True

    Thats all, Trigger the Build Definition by setting Configuration=myconfigfilesname Platform =Any CPU. :)

    Thanks,


    Abraham Dhanyaraj

    Friday, March 13, 2015 10:17 AM

All replies

  • Hi Abraham,  

    Thanks for your post.

    What’s the version of your TFS and VS?

    How did specific your solution using Web.Live.Config file when you manually publish to a Filesystem?

    Have you added that MSBuild target in your CSPROJ file followed the example in first article? If yes, please manually execute MSBuild command within /p:IsTFSBuild=True argument to build your solution manually, then check the result. You need ensure MSBuild command line can build your solution as expect, then build your solution using TFS Build.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 13, 2015 2:54 AM
    Moderator
  • Hi John ,

    Thanks for your inputs. Worked after making this modification 

    Mod 1 : Added the below tags in .csproj 

                 <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
      <Target Name="AfterBuild" Condition="'$(IsTFSBuild)' != ''">
        <Message Text="'Message After Build: TFSBuild Status $(IsTFSBuild) - $(OutDir)\_PublishedWebsites\$(TargetName) '" />
        <TransformXml Condition="Exists('$(OutDir)\_PublishedWebsites\$(TargetName)')" Source="Web.config" Transform="Web.$(Configuration).config" Destination="$(OutDir)\_PublishedWebsites\$(TargetName)\Web.config" />
      </Target>

    Mod 2 : Build manuall using msbuild D:\ADEC\Demo12\Demo12\Demo12.csproj /p:Configuration=myconfigfilesname /p:IsTFSBuild=True

    Thats all, Trigger the Build Definition by setting Configuration=myconfigfilesname Platform =Any CPU. :)

    Thanks,


    Abraham Dhanyaraj

    Friday, March 13, 2015 10:17 AM
  • Might this not be better?:

    MSBuild arguments = /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false

    You don't have to change you project file using this technique. See my blog post here where I use it to create a tokenised web.config.

    Cheers - Graham


    Blog: http://pleasereleaseme.net   LinkedIn:

    Friday, March 13, 2015 5:22 PM