Description
To convert your configuration file, you need to fulfill the TransformWebConfig target.
This target takes two Web.config and Web.$(Configuration).config and generates Web.config . The generated file is a converted version of the source for the current configuration.
This file is created in the folder: obj\$(Configuration)\TransformWebConfig
Using
You really do not explain what you want to achieve, therefore the main use here is the task that generates the converted configuration file in this folder.
Add the following snippet to the end of the *.csproj project file after importing Microsoft.WebApplication.targets
<PropertyGroup> <TransformedWebConfigDestination>$(MSBuildProjectDirectory)</TransformedWebConfigDestination> </PropertyGroup> <Target Name="ConfigSubstitution"> <CallTarget Targets="TransformWebConfig"/> <ItemGroup> <TransformedWebConfig Include="obj\$(Configuration)\TransformWebConfig\Web.config"/> </ItemGroup> <Copy SourceFiles="@(TransformedWebConfig)" DestinationFolder="$(TransformedWebConfigDestination)"/> </Target>
In Hudson, you can add an assembly step to your assembly or create a task configured as follows:
- MsBuild assembly file:
Your csproj file. - Command-line arguments:
/t:ConfigSubstitution /p:Platform=AnyCpu;Configuration=Test;TransformedWebConfigDestination=DestinationFolder
Julien Hoarau
source share