Converting a configuration to a WIX setup
I am creating an MSI install with WIX for my web application. This works correctly. The only thing I don't get is to enable the configuration transformation of the standard web application publishing method.
I understand that you can add a use tag for existing target files. I tried adding TransformXml
to the AfterBuild object in the WIX installer project file, but it doesn't work.
<TransformXml Source="Web.Config" Transform="Web.$(Configuration).config" Destination="Web.Config" />
Can anyone help me?
I created a test project for this WebApplicationWix
+2
source to share
1 answer
I haven't seen any mention of TransformXml in your sample project.
You need code like this:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile">
<CallTarget Targets="TransformWebConfiguration" Condition="Exists('web.$(Configuration).config')"/>
</Target>
<Target Name="TransformWebConfiguration">
<!-- Generate transformed web configuration -->
<TransformXml Source="web.config" Destination="web.transformed.config" Transform="web.$(Configuration).config" />
</Target>
A few notes:
- Check the path to Microsoft.Web.Publishing.Tasks.dll in UsingTask (change for your version of Visual Studio)
- In your example, the source and destination were the same; you have to make sure the destination is a different file so that you don't have any file locking problems or the web.config file you are trying to convert with the converted is overwritten.
- Visual Studio 2010 had file locking issues with TransformXml, so be careful if you are using 2010.
+2
source to share