“不是有效的外键” XmlFile 元素错误

发布于 2024-10-06 09:12:37 字数 1701 浏览 0 评论 0原文

我正在尝试使用 WIX (v3.5) 安装程序中的 XmlFile 元素来更新正在安装的 web.config 中的连接字符串。但我发现以下错误。

不是有效的外键;桌子: XmlFile,列:文件,键: 更新连接字符串

web.config 组件和文件元素位于使用 Heat 获取的 .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/[电子邮件受保护]/msg03256.html

I'm trying to use the XmlFile element in a WIX (v3.5) installer to update the connection string in the web.config that's being installed. But I'm getting the following error in light.

Not a valid foreign key; Table:
XmlFile, Column: File, Key(s):
UpdateConnectionString

The web.config Component and File elements are located in a .wxs that is harvested using Heat. Here's what it looks like in "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>

Here is the Component I've used most recently in "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>

Here are some reference page that I've used so far:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

誰認得朕 2024-10-13 09:12:37

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

Ids in MSI and WiX are case-sensitive. Your XmlFile uses Web.Config but the file's id is Web.config.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文