问题描述
这是我使用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>
仅此而已,文件内没有更多内容。也没有任何其他本地化文件。但是,当我尝试构建te WIX项目时,却遇到9个有关重复标识符的错误:
本地化标识符“ xx”已在多个位置重复。请解决冲突。
我的 common.wxl
中的每个ID都有一个错误。但是我没有其他本地化文件,那么这些标识符如何重复?
我已经尝试解决好几个小时了……有人知道吗?
我正在使用WiX Toolset 3.11.2和WiX Toolset Visual Studio 2019 Extension。
解决方法
WiX本地化 :请尝试以下WiX本地化示例:https://github.com/glytzhkof/all/blob/master/WiXLocalizationSample.zip
务实的建议 :如果此示例项目适合您,请考虑创建一个新的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
。