I’m using the config file replacement feature of Visual Studio 2010’s “Publish” functionality, as described in this article. I want to automate this using MSBuild/Hudson. Does anybody know how to do this?
I like how it works but if I cannot automate it I’ll have to switch to XmlMassUpdate or similar.
Explanation
To transform your config file you’ll have to execute the
TransformWebConfigtarget.This target takes two files
Web.configandWeb.$(Configuration).configand generates aWeb.config. The generated file is the transformed version of the original one for the current configuration.This file is generated in folder :
obj\$(Configuration)\TransformWebConfigUsage
You don’t really explain what you want to achieve, so here a basic usage, a job that generates a transformed config file in a given folder.
Add the following piece in the end of your project file
*.csprojafter the import ofMicrosoft.WebApplication.targetsIn Hudson you could add a Build step in your build, or create a dedicated job configured as follow:
Your csproj file./t:ConfigSubstitution /p:Platform=AnyCpu;Configuration=Test;TransformedWebConfigDestination=DestinationFolder