这是我使用 Wix Toolset 和 Visual Stdio 的第一个项目 - 我不算“Hello World”类型应用程序的简单教程。
在我当前的项目中,我只有一个本地化文件,名为 common.wxl:
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="Company">TestCompany</String>
<String Id="ProductNameFolder">TestApp/[Buildversion]</String>
<String Id="ProductName_x86">TestApp</String>
<String Id="ProductName_x64">TestApp</String>
<String Id="Description">Test Description</String>
<String Id="Comments">Designed by TestCompany</String>
<String Id="Keywords">application, installer</String>
<String Id="DowngradeErrorMessage">A newer version of [ProductName] is already installed.</String>
<String Id="Language">1033</String>
</WixLocalization>
就这样,文件中没有其他内容了。此外,没有任何其他本地化文件。不过,当我尝试构建 WIX 项目时,我收到了 9 个关于重复标识符的错误:
本地化标识符“xx”已在多个位置重复。请解决冲突。
我的
common.wxl
中的每个 ID 都有一个错误。但我没有任何其他本地化文件,那么如何复制这些标识符?
我已经尝试解决这个问题几个小时了...有人有任何想法吗?
我正在使用 WiX Toolset 3.11.2 和 WiX Toolset Visual Studio 2019 Extension。
WiX 本地化:请尝试此 WiX 本地化示例:https://github.com/glytzhkof/WiXLocalizationSample
实用建议:如果此示例项目适合您,请考虑创建一个新的 WiX 项目并一次迁移一个构造,同时不断检查构建。可能包含导致此类重复错误的不必要的文件。也许还可以尝试更改
String Id
字段 - 例如从 Description
更改为 MyDescription
。只是为了测试。
您可以使用
"!(loc.StringID)"
格式引用本地化文件中的标识符。这将在构建 MSI 时使用实际字符串扩展这些占位符值。这是一个压缩样本:
在您的
Project.wxs
文件中:
<Product Id="*" Name="WixLocalizationSample" Language="1033" Version="1.0.0.0"
Manufacturer="!(loc.Company)" UpgradeCode="PUT-GUID-HERE" >
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"
Comments="!(loc.Comments)" Keywords="!(loc.Keywords)"
Description="!(loc.Description)" />
在您的本地化文件中 (
English.wxl
):
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="Description">This is a long test description.</String>
<String Id="Comments">Designed by TestCompany</String>
<String Id="Keywords">application, installer</String>
<String Id="Company">TestCompany</String>
</WixLocalization>
如果需要转义 XML 分隔符,请使用
CDATA
。
我正在从一个存储库迁移到另一个存储库,并对旧安装程序进行一些改进,但我遇到了同样的问题。本地化文件位于安装程序项目引用的 Wix 库项目中。该错误是因为 Wix 库项目文件夹与安装程序项目文件位于同一目录中。
此结构产生错误:
solution/
├─ solution.sln
├─ installer.wixproj
├─ lib/
| ├─ localization.wxl
一旦我改变了如下结构,它就没有抱怨:
solution/
├─ solution.sln
├─ installer.wixproj
lib/
├─ localization.wxl