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
精彩评论