1

I am trying to run a MSBuild task on team city that also transforms a web.casper.config file.

I have tried various switches but can;t get this right. Which most likely means there is a different way to achieve my desired result (like publish).

I have tried:-

/t:TransformWebConfig /p:TransformWebConfig=true

Basically I want to - BUILD website.csproj into a custom dir - THEN apply a web.config transform on web.casper.config

Can anyone help?

Team city settings

Rippo
  • 22,117
  • 14
  • 78
  • 117

1 Answers1

2

One thing that seems to work (not sure if its the best way) is to add a before/after build event on the csproj file for the website e.g.

  <Target Name="BeforeBuild">
    <Copy SourceFiles="Web.config" DestinationFiles="Web.temp.config"
         OverwriteReadOnlyFiles="True" />
    <TransformXml Source="Web.temp.config" Transform="Web.$(Configuration).config" 
         Destination="Web.config" />
  </Target>
  <Target Name="AfterBuild">
    <Copy SourceFiles="Web.temp.config" DestinationFiles="Web.config"   
       OverwriteReadOnlyFiles="True" />
    <Delete Files="Web.temp.config" />
  </Target>

This basically copies web.config to web.temp.config then uses the casper config to transform.

Source from SO

Community
  • 1
  • 1
Rippo
  • 22,117
  • 14
  • 78
  • 117