Xml File Preprocessor User's Guide XmlPreprocessor 1.0

MSI Integration

MSI Integration

Sample of integration with Visual Studio .NET installer

Add a custom page with two text boxes to the installer's UI to collect the settings file name into a property named SETTINGSFILE, and optionally additional custom properties into a property named CUSTOMSETTINGS

Add the XmlPreprocess.exe file to the installer

Add a custom action that invokes XmlPreprocess.exe with the appropriate command line parameters, for example:

/s "[SETTINGSFILE]" /i "[TARGETDIR]web.config" [CUSTOMSETTINGS]

Sample of integration with WiX installer

<Wix>
  <Product>
    :
    <CustomAction Id="WEB_CONFIG" BinaryKey="XMLPREPROCESS" ExeCommand="/s &quot;[SETTINGSFILE]&quot; /i &quot;[TARGETDIR]Web.config&quot; [CUSTOMSETTINGS]" Execute="deferred" />
    <CustomAction Id="CustomTextA_SetProperty_EDIT2" Property="CUSTOMSETTINGS" Value="[CUSTOMSETTINGS]" Execute="firstSequence" />
    <CustomAction Id="CustomTextA_SetProperty_EDIT1" Property="SETTINGSFILE" Value="[SETTINGSFILE]" Execute="firstSequence" />
    :
    <Dialog Id="CustomTextA" Width="373" Height="287" Title="[ProductName]">
        <Control Id="NextButton" Type="PushButton" X="300" Y="261" Width="66" Height="18" Default="yes">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}&amp;Next &gt;</Text>
        <Publish Event="EndDialog" Value="Return"><![CDATA[CustomTextA_NextArgs=""]]></Publish>
        <Publish Event="NewDialog" Value="[CustomTextA_NextArgs]"><![CDATA[CustomTextA_NextArgs<>""]]></Publish>
        </Control>
        <Control Id="Label1" Type="Text" X="18" Y="108" Width="348" Height="12" TabSkip="no">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}Enter the full path to the settings XML File: (ex: c:\deployment\qa_settings.xml)</Text>
        </Control>
        <Control Id="Edit1" Type="Edit" X="18" Y="120" Width="348" Height="18" Property="SETTINGSFILE" Sunken="yes">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}</Text>
        </Control>
        <Control Id="Label2" Type="Text" X="18" Y="144" Width="348" Height="12" TabSkip="no">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}Additional custom settings to override those in settings file. (ex: /d server=foo /d protocol=tcp)</Text>
        </Control>
        <Control Id="Edit2" Type="Edit" X="18" Y="156" Width="348" Height="18" Property="CUSTOMSETTINGS" Sunken="yes">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}</Text>
        </Control>
        <Control Id="Label3" Type="Text" X="18" Y="180" Width="348" Height="12" Hidden="yes" TabSkip="no">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}Edit3:</Text>
        </Control>
        <Control Id="Edit3" Type="Edit" X="18" Y="192" Width="348" Height="18" Property="EDITA3" Hidden="yes" Sunken="yes">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}</Text>
        </Control>
        <Control Id="Label4" Type="Text" X="18" Y="216" Width="348" Height="12" Hidden="yes" TabSkip="no">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}Edit4:</Text>
        </Control>
        <Control Id="Edit4" Type="Edit" X="18" Y="228" Width="348" Height="18" Property="EDITA4" Hidden="yes" Sunken="yes">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}</Text>
        </Control>
        <Control Id="CancelButton" Type="PushButton" X="156" Y="261" Width="66" Height="18" Cancel="yes">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}Cancel</Text>
        <Publish Event="SpawnDialog" Value="Cancel"><![CDATA[]]></Publish>
        </Control>
        <Control Id="PreviousButton" Type="PushButton" X="228" Y="261" Width="66" Height="18">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}&lt; &amp;Back</Text>
        <Publish Event="NewDialog" Value="[CustomTextA_PrevArgs]"><![CDATA[CustomTextA_PrevArgs<>""]]></Publish>
        <Condition Action="disable"><![CDATA[CustomTextA_PrevArgs=""]]></Condition>
        <Condition Action="enable"><![CDATA[CustomTextA_PrevArgs<>""]]></Condition>
        </Control>
        <Control Id="BannerBmp" Type="Bitmap" X="0" Y="0" Width="375" Height="52" TabSkip="no" Text="DefBannerBitmap" />
        <Control Id="BannerText" Type="Text" X="9" Y="9" Width="306" Height="33" Transparent="yes">
        <Text>{\VSI_MS_Sans_Serif16.0_1_0}Configuration Settings</Text>
        </Control>
        <Control Id="BodyText" Type="Text" X="9" Y="63" Width="354" Height="42">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}Enter configuration settings information. These environment specific settings will automatically be merged into the configuration files using the CfgPreprocess tool.</Text>
        </Control>
        <Control Id="Control273" Type="Line" X="0" Y="252" Width="375" Height="6">
        <Text>{\VSI_MS_Sans_Serif13.0_0_0}MsiHorizontalLine</Text>
        </Control>
        <Control Id="Control278" Type="Line" X="0" Y="52" Width="375" Height="6">
        <Text>{\VSI_MS_Sans_Serif16.0_1_0}MsiHorizontalLine</Text>
        </Control>
    </Dialog>
    <InstallExecuteSequence>
        :
        <Custom Action="WEB_CONFIG" After="StartServices"><![CDATA[SETTINGSFILE<>"" AND NOT Installed]]></Custom>
    </InstallExecuteSequence>
    :
    <Binary Id="XMLPREPROCESS" src="XmlPreprocess.exe" />
  </Product>
</Wix>