2
votes

I'm creating a MSI setup with WIX for my Web Application. This works correct. The only thing that I don't get to work is to enabling the config transformation of the standard web application publish method.

I understand that you can add the using tag for existing target files. I try'ed to add the TransformXml to the AfterBuild Target in the project file of the WIX installer but that doesn't work.

<TransformXml Source="Web.Config" Transform="Web.$(Configuration).config" Destination="Web.Config" />

Can someone help me?

I created a test project for this called WebApplicationWix

1

1 Answers

2
votes

I didn't see any mention of TransformXml in your example project.

You need code similar to 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 things to note:

  1. Check the path to Microsoft.Web.Publishing.Tasks.dll in the UsingTask element (change for your version of Visual Studio)
  2. In your example, the source and destination were the same; you should make sure the destination is a different file so that you don't have file lock issues or overwrite the web.config you're trying to transform with the transformed one.
  3. In Visual Studio 2010, there were file locking issues with TransformXml, so be careful of that if you're using 2010.