【问题标题】:Add resource files in wix installer在 wix 安装程序中添加资源文件
【发布时间】:2017-10-06 17:40:53
【问题描述】:

我创建了一个多语言应用程序,它使用 2 个不同的资源文件来管理 UI 语言,所以当我构建和执行我的程序时,在我的 bin 目录中我有我的应用程序文件和两个文件夹,en-GB 和 pt- PT。

我现在正在尝试使用 Wix 创建安装程序,为此我定义了以下目录:

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
         <Directory Id="INSTALLFOLDER" Name="App" >
            <Directory Id="LOCALEEN" Name="en-GB"/>
            <Directory Id="LOCALEPT" Name="pt-PT"/>
          </Directory>
      </Directory>
    </Directory>
  </Fragment>

然后,我定义了以下组件:

 <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="App.resources.en.GB.dll" Guid="...">
        <CreateFolder />
        <File Id="App.resources.en.GB.dll" Name="App.resources.dll" Source="$(var.App.App_TargetDir)en-GB\App.resources.dll" />
      </Component>

    <Component Id="App.resources.pt.PT.dll" Guid="...">
        <CreateFolder />
        <File Id="App.resources.pt.PT.dll" Name="App.resources.dll" Source="$(var.App.App_TargetDir)pt-PT\App.resources.dll" />
      </Component>

    ... Other components...

    </ComponentGroup>
  </Fragment>

当我重建我的解决方案时,我收到以下错误:

'App.resources.dll' 被两个安装在'[ProgramFilesFolder]\App\' 中 LFN 系统上的不同组件:“App.resources.en.GB.dll”和 'App.resources.pt.PT.dll'。这会破坏组件引用计数。

我明白这个问题,两个资源dll都被复制到安装文件夹,而不是具体的资源文件......但我不知道如何解决它。任何人都可以就如何解决这个问题提供任何提示?

【问题讨论】:

    标签: wix components


    【解决方案1】:

    只需引用您想要组件的目录,例如。 Directory="LOCALEEN"。无需指定&lt;CreateFolder /&gt; 我还建议保持某种命名约定。您的组件和文件具有相同的 id。见https://stackoverflow.com/a/1801464/4634044。所以这应该符合你的期望:

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="C_EnglishLocale" Guid="..." Directory="LOCALEEN">
                <File Id="Fi_EnglishLocale" Name="App.resources.dll" Source="$(var.App.App_TargetDir)en-GB\App.resources.dll" />
            </Component>
    
            <Component Id="C_PolnishLocale" Guid="..." Directory="LOCALEPT">
                <File Id="Fi_PolnishLocale" Name="App.resources.dll" Source="$(var.App.App_TargetDir)pt-PT\App.resources.dll" />
            </Component>
        </ComponentGroup>
    </Fragment>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-22
      • 1970-01-01
      • 1970-01-01
      • 2011-10-03
      • 1970-01-01
      • 1970-01-01
      • 2010-11-20
      • 1970-01-01
      相关资源
      最近更新 更多