Home > Windows Installer XML > WIX: Update Application Configuration Files during Installation

WIX: Update Application Configuration Files during Installation


Often we need to modify application configuration files during installation of the application. Generally to set some application settings, or modify database connection strings etc. We can do this in WIX by using the <util:XmlFile/> custom actions. To use these custom actions we need to reference WIXUtilExtension to the setup project.


<util:XmlFile Id="UpdateConnectionString"


The File attribute specifies the ID of the configuration file which is defined using the <File/> element in WIX source file; ElementPath specifies the XPATH to an element in the configuration file which needs to be modified, Action specifies what to do with the element; it should be either createElement, deleteElement, setValue, or bulkSetValue. And the Value specifies the target value to be set to the element. Mostly we would use a Property that has been set by the installer UI sequence as a target value.

Below example shows how to modify the connection string DBConn and the application setting MySetting in the Web.Config file.


<Component Id=”ConfigureWebConfig” Guid=*>
 <File Id=”MyConfigfile” Source=”$(var.Configuration)\web.config” KeyPath=”yes” />

<!-- update a connection string  -->
<util:XmlFile Id="UpdateConnectionString"
  Value="Server=[DBSERVER];Database=[DBNAME];Integrated Security=SSPI;"/>

<!-- update an application setting  -->
<util:XmlFile Id="UpdateMySetting"
  Value="[TARGETVALUE]" />


Note that we need to escape the square brackets in XPATH to the element.


Hope it helps.

🙂 ranjith 🙂

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: