4
votes

I'm using Team City to handle our deployment.

So I created a MSBuild step to compile our .sln file.

After the build I have these three files in my output directory :

  • Web.config
  • Web.Release.config
  • Web.Debug.config

That means that the msbuild task doesn't transform the web.config.

But when I use the publish functionality in visual studio , the transformation is done.

So, what's the difference between a msbuild and a publish ? And how can I force my msbuild task to transform the config ?

1
I am not sure if I understand what you meant by "doesn't transform the web.config"? - Arun
In my output directory I have only the 3 web.config.* files, Id like to have only 1 web.config with the transformation applied - remi bourgarel

1 Answers

1
votes

I found my answer here

http://cgeers.com/2011/08/21/web-config-transformation-using-teamcity/

Here is my task :

<Target Name="Publish">    
   <RemoveDir Directories="$(DestinationPath)" ContinueOnError="true" />         
   <MSBuild Projects="$(SourcePath)/$(ProjectFile)" Targets="Rebuild;ResolveReferences;_CopyWebApplication" Properties="WebProjectOutputDir=$(DestinationPath);OutDir=$(DestinationPath)\bin\" />  

   <TransformXml Source="$(SourcePath)/Web.Config" Transform="$(SourcePath)/Web.$(Configuration).config" Destination="$(DestinationPath)/Web.config" />
   <ItemGroup>
      <FilesToDelete Include="$(DestinationPath)/Web.*.config"/>
   </ItemGroup>
   <Delete Files="@(FilesToDelete)"/>
</Target>

You call it like this

 <MSBuild Projects="$(MSBuildProjectFullPath)" 
         Targets="Publish" 
         Properties="Configuration=Release;ProjectFile=WebProject.csproj;SourcePath=C:\webproject\;DestinationPath=C:\inetpub\wwwroot\app\"/>

Thanks