none
TFS 2010 build config transform problem

    Question

  • Hi all,

    I'm facing quite a problem while setting up automated TFS Builds. Basically I created new configuration called Tests, added transform config, defined different connection string for the Database. Then defined TFS build, building whole solution with MSBuild arguments /p:DeployOnBuild=True /p:Configuration=Tests. The problem is that in the drop location (Build_PublishedWebsites\Project) I get web.config, web.debug.config, web.release.config and web.tests.config, however I would expect just one transformed web.config.

    I already checked PDC presentation (http://microsoftpdc.com/Sessions/FT56), but didn't help.

    Thanks for any answer.

    Zdenek

    Friday, April 23, 2010 1:13 PM

Answers

  • Here is how I solved this.  The key was to edit the *.csproj file on the website and add the following to the AfterBuild target (be sure to move the end comment above it).  This is for our website build project in Team Foundation Server.

     <Target Name="AfterBuild">
      <TransformXml Condition="Exists('$(OutDir)\_PublishedWebsites\$(TargetName)')" Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(OutDir)\_PublishedWebsites\$(TargetName)\Web.config" />
     </Target>
    

    To keep the web.debug.config, web.release.config, etc... from being published be sure to set the "Build Action" in the properties window for each of the config transformation files to "None".  Only the main web.config should have a "Build Action" of "Content"

    One easy way to edit the csproj file is to load either the "PowerCommands for Visual Studio 2010" or "Productivity Power Tools" Extension to Visual Studio 2010 available from the Visual Studio Gallery.  Once loaded all you have to do is right click on the project in your solution and select "Unload Project".  Then you can right click again and select "Edit..." to edit the csproj file XML directly.  Then when done just right click again and select "Reload Project".

     

    Friday, July 23, 2010 6:41 PM

All replies

  • Hello zdenek,

    I'm not sure if passing in the Configure property is going to actually do anything.  Are you using Team Build 2010 or 2008? 

    If you're using 2008 check your tfsBuild.proj and see what your ConfigurationToBuild itemgroup is set too.  Edit this so that you're only building the Test configuration.

    In 2010 (assuming Default Template) try editing your build definition and check the Process area.  Expand the "Items to Build" field and check what your Configuration to Build is set too.

    I hope this helps.

    Regards,

    Jason

    Friday, April 23, 2010 2:58 PM
  • I setted "Configurations to build" to Tests and it still doesn't work. my platform is Any CPU that is the same as in my project. The build is the default TFS. Don't really know where can be the problem. When I just Create package from visual studio it works and I get my transformed config.

    Zdenek

    Btw. I am using TFS 2010

    Friday, April 23, 2010 3:38 PM
  • Here is how I solved this.  The key was to edit the *.csproj file on the website and add the following to the AfterBuild target (be sure to move the end comment above it).  This is for our website build project in Team Foundation Server.

     <Target Name="AfterBuild">
      <TransformXml Condition="Exists('$(OutDir)\_PublishedWebsites\$(TargetName)')" Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(OutDir)\_PublishedWebsites\$(TargetName)\Web.config" />
     </Target>
    

    To keep the web.debug.config, web.release.config, etc... from being published be sure to set the "Build Action" in the properties window for each of the config transformation files to "None".  Only the main web.config should have a "Build Action" of "Content"

    One easy way to edit the csproj file is to load either the "PowerCommands for Visual Studio 2010" or "Productivity Power Tools" Extension to Visual Studio 2010 available from the Visual Studio Gallery.  Once loaded all you have to do is right click on the project in your solution and select "Unload Project".  Then you can right click again and select "Edit..." to edit the csproj file XML directly.  Then when done just right click again and select "Reload Project".

     

    Friday, July 23, 2010 6:41 PM
  • I added this . It works beautifully on my local but when I test it on TFS. It does copy the transformed config file to the final output folder but the package  zip file contains untransformed web.config.

    Reason being on TFS server package is created before transformation and on my local package gets created after transformation. Am I the only one missing something pretty obvious.

    Please help.

    Tuesday, August 14, 2012 5:19 PM