2010-12-08 82 views
0

我試圖在WIX(v3.5)安裝程序中使用XmlFile元素來更新正在安裝的web.config中的連接字符串。但我得到以下錯誤。XmlFile元素「無效的外鍵」錯誤

不是有效的外鍵;表: XMLFILE,柱:文件,密鑰(或多個): UpdateConnectionString

在web.config元器件和文件元件位於正在使用熱收穫了.wxs。下面是它看起來像在「Site.Components.wxs」:

 <Component Id="Web.config" Guid="{E66D901B-8140-4162-96F3-8A29253659FE}"> 
      <File Id="Web.config" KeyPath="yes" Source="$(var.WEBSOURCEFOLDER)\Web.config" /> 
     </Component> 

這是我最近使用過的「Site.Feature.wxs」

<Directory Id="SiteRoot" Name="SiteRoot"> 
    ... 
    <Component Id="WebConfigChanges" Guid="{A242616E-5515-4E77-8CB3-361A449118A4}" > 
     <RegistryValue Id="WebConfigChanged" Root="HKLM" Key="SOFTWARE\CompanyName\ProductName" Name="WebConfigChanged" Value="1" Action="write" Type="string" KeyPath="yes" /> 
     <util:XmlFile Id="UpdateConnectionString" 
      File="[#Web.Config]" 
      Action="setValue" 
      ElementPath="//configuration/connectionStrings/add[\[]@name=’Default’[\]]/@connectionString" 
      Value="[CONNNECTIONSTRING]"/> 
    </Component> 
    </Directory> 

這裏有一些參考的組件我到目前爲止已經使用的頁:

http://ranjithk.com/2009/11/06/wix-update-application-configuration-files-during-installation/

http://www.mail-archive.com/[email protected]/msg03256.html

回答

2

MSI和WiX中的ID區分大小寫。您的XmlFile使用Web.Config,但文件的ID是Web.config。

+0

duh!我會發誓要複製/粘貼該密鑰......並且可能在某一時刻完成。我現在更好地理解錯誤消息。這是說文件屬性是它遇到麻煩的關鍵。我一直在想,它不知道'UpdateConnectionString'Id。謝謝! – Rick 2010-12-09 16:31:51

相關問題