开发者

Run MSBuild on a csproj doesn't apply web.config transofmration

开发者 https://www.devze.com 2023-03-30 22:40 出处:网络
I\'m using Team City to开发者_Go百科 handle our deployment. So I created a MSBuild step to compile our .sln file.

I'm using Team City to开发者_Go百科 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 ?


I found my answer here

https://github.com/geersch/TeamCity/blob/master/src/part-3/README.md

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

0

精彩评论

暂无评论...
验证码 换一张
取 消