The syntax for the web.config edit is kind of tricky, and I don't
understand it 100%, but I 'borrowed' some code off the 'net somewhere
(which I always have trouble finding again) that I use as a template
every time. We put our web.config edits in a separate component that
ultimately looks like this (sorry about the wordwrap, the lines are
long):

 

          <Component Id="EditWebConfig" Guid="" KeyPath="yes">

            <util:XmlFile Id="RequireCorrectCaptchaCode"
Action="setValue"
ElementPath="/configuration/appSettings/[EMAIL PROTECTED]'RequireCorrectCaptc
haCode'[\]]/@value" File="[INSTALLDIR]Web.config"
Value="[[TARGET_ENVIRONMENT].CAPTCHA_REQUIRED]" />

            <util:XmlFile Id="AllowAccountAlertTraffic"
Action="setValue"
ElementPath="/configuration/appSettings/[EMAIL PROTECTED]'AllowAccountAlertTr
affic'[\]]/@value" File="[INSTALLDIR]Web.config"
Value="[[TARGET_ENVIRONMENT].ACCOUNT_ALERTS_TRAFFIC]" />

            <util:XmlFile Id="CustomErrorsMode" Action="setValue"
ElementPath="/configuration/system.web/customErrors/@mode"
File="[INSTALLDIR]Web.config"
Value="[[TARGET_ENVIRONMENT].CUSTOM_ERRORS_MODE]" />

            <util:XmlFile Id="Log4NetFilePath" Action="setValue"
ElementPath="/configuration/log4net/appender/[EMAIL PROTECTED]'File'[\]]/@
value" File="[INSTALLDIR]Web.config"
Value="[[TARGET_ENVIRONMENT].LOG4NET_PATH]" />

          </Component>

 

Your ElementPath will have to be changed to point at the connection
string stuff. We don't edit our connection strings on the fly, but
something similar to the 'customErrors' line above should work. The
'Value' tags above are set with public variables that are set elsewhere
in our installers, but they could very well be literal (which, by the
way, wouldn't make sense as I would suspect the reason to edit the
web.config on the fly is to change these settings at runtime. If they're
hard coded here, why not just check them in that way?)

 

Two more things you'll have to do (note I'm working with Wix3, Wix2
might be slightly different, I can't recall):

 

1.      Make sure your Wix tag references the util extension, as well as
the iis extension, schemas:

 

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension";
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension";>

 

2.      Link those babies in during compile and link:

 

   candleArgs: "<projectfile>" -out "<projectname>.wixobj" -ext
"C:\Program Files\Windows Installer XML v3\bin\WixIIsExtension.dll" -ext
"C:\Program Files\Windows Installer XML v3\bin\WixUtilExtension.dll"

    lightArgs: "<projectname>.wixobj" -out "<projectname>.msi" -ext
"C:\Program Files\Windows Installer XML v3\bin\WixIIsExtension.dll" -ext
"C:\Program Files\Windows Installer XML v3\bin\WixUtilExtension.dll"
-cultures:en-us -sval

 

It's just that easy! :-)

 

 

-Matt

 

  _____  

From: Stepan Tinskiy [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 22, 2007 12:42 AM
To: [email protected]
Subject: [WiX-users] editing web.config file

 

Hi all.

Does anybody have an example how to editing web.config actually
connection string properties during installing process? 

Thx in advance. 

 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to