Running MSBuild on csproj does not apply. Web.config transofmration

I use Team City to handle our deployment.

So, I created an 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

This means that the msbuild task does not convert the web.config file.

But when I use the publish function in visual studio, the conversion is done.

So what is the difference between msbuild and posting? And how can I get the msbuild task to convert the configuration?

+4
source share
1 answer

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

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

thanks

+1
source

Source: https://habr.com/ru/post/1368969/


All Articles