Skip to the content.

Edit JSON files from WiX installers

WixJsonFileExtension is a WiX Toolset extension for changing JSON configuration files, such as appsettings.json, during an MSI install, repair or uninstall. It adds a JsonFile element that works like util:XmlFile does for XML: you name the file, a JSONPath and a value, and the extension does the deferred, elevated, rolled-back work. There is no custom action code to write.

Quick start

Add the package to your .wixproj:

<PackageReference Include="WixJsonFileExtension" Version="7.1.0" />

Declare the namespace and add JsonFile elements to the component that installs the file:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
     xmlns:Json="http://schemas.hegsie.com/wix/JsonExtension">
  ...
  <Component Id="AppConfig">
    <File Id="AppSettings" Name="appsettings.json" Source="appsettings.json" />

    <Json:JsonFile Id="SetConnection" File="[#AppSettings]"
                   ElementPath="$.ConnectionStrings.DefaultConnection"
                   Value="Server=[DB_SERVER];Database=[DB_NAME];Trusted_Connection=True"
                   Action="setValue" />
  </Component>

Guides

Code signing

Free code signing provided by SignPath.io, certificate by SignPath Foundation. See the code signing policy.