确定先前软件包版本的 WiX 错误
Posted
技术标签:
【中文标题】确定先前软件包版本的 WiX 错误【英文标题】:WiX Error Determining Previous Package Version 【发布时间】:2016-09-20 14:18:01 【问题描述】:遇到版本号问题。
我们曾经为我们的客户端安装程序使用 Installshield。自从切换到 WiX 后,我们已经“修复”了一些问题,例如版本编号方案。我们曾经使用 x.x.x-y,但 WiX 不允许“-”作为版本号的一部分。
当我尝试使用“虚线”版本 # 更新已安装的旧产品时,安装停止(甚至在开始之前):
[09A4:1908][2016-09-20T09:20:34]e000: Error 0x80070057: Failed to convert version: 5.3.0-7 to DWORD64 for ProductCode: ...
[09A4:1908][2016-09-20T09:20:34]e151: Detect failed for package: Client_MSI, error: 0x80070057
该错误似乎导致引擎无法触发 OnDetectMsiFeature,但是,引擎似乎确实以某种方式知道这些功能:
[09A4:1908][2016-09-20T09:20:34]i000: WixWPF: Enter Method: OnDetectPackageComplete
[09A4:1908][2016-09-20T09:20:34]i000: WixWPF: Leaving Method: OnDetectPackageComplete
[09A4:1908][2016-09-20T09:20:34]i101: Detected package: NetFx40Web, state: Present, cached: None
[09A4:1908][2016-09-20T09:20:34]i101: Detected package: vcredist2015x64, state: Present, cached: Complete
[09A4:1908][2016-09-20T09:20:34]i101: Detected package: vcredist2015x86, state: Present, cached: None
[09A4:1908][2016-09-20T09:20:34]i101: Detected package: Client_MSI, state: Unknown, cached: None
[09A4:1908][2016-09-20T09:20:34]i104: Detected package: Client_MSI, feature: FeatureA, state: Unknown
[09A4:1908][2016-09-20T09:20:34]i104: Detected package: Client_MSI, feature: FeatureB, state: Unknown
...
[09A4:1908][2016-09-20T09:20:34]i000: WixWPF: Enter Method: OnDetectComplete
更新:
我用 dutil\fileutil.cpp 的版本号跟踪问题。我将第 444 行的检查更改为:
while (wzPartEnd < wzEnd && ((L'.' != *wzPartEnd)
&& (L'-' != *wzPartEnd)))
soas 接受 '-' 作为版本分隔符。现在,新的引导程序加载,但在状态检测方面存在问题。虽然它“看到”包和功能,但它“看到”所有这些都是“不存在的”。
[0280:1050][2016-09-20T12:36:05]i103: Detected related package: ..., scope: PerMachine, version: 5.3.0.7, language: 0 operation: MajorUpgrade
[0280:1050][2016-09-20T12:36:05]i000: WixWPF: Enter Method: OnDetectRelatedMsiPackage
[0280:1050][2016-09-20T12:36:05]i000: WixWPF: Leaving Method: OnDetectRelatedMsiPackage
[0280:1050][2016-09-20T12:36:05]i000: WixWPF: Enter Method: OnDetectMsiFeature
[0280:1050][2016-09-20T12:40:42]i000: WixWPF: Leaving Method: OnDetectMsiFeature
...
[0280:1050][2016-09-20T12:41:04]i000: WixWPF: Enter Method: OnDetectPackageComplete
[0280:1050][2016-09-20T12:41:07]i000: WixWPF: Leaving Method: OnDetectPackageComplete
[0280:1050][2016-09-20T12:41:07]i101: Detected package: NetFx40Web, state: Present, cached: None
[0280:1050][2016-09-20T12:41:07]i101: Detected package: vcredist2015x64, state: Present, cached: Complete
[0280:1050][2016-09-20T12:41:07]i101: Detected package: vcredist2015x86, state: Present, cached: None
[0280:1050][2016-09-20T12:41:07]i101: Detected package: Client_MSI, state: Absent, cached: None
[0280:1050][2016-09-20T12:41:07]i104: Detected package: Client_MSI, feature: LunaClient, state: Absent
[0280:1050][2016-09-20T12:41:07]i104: Detected package: Client_MSI, feature: FeatureB, state: Absent
所以,我的新问题是:
-
为什么旧包和选定的功能列表都标记为不存在?
我可以从中恢复吗?
【问题讨论】:
【参考方案1】:在我开始工作一个月后更新它。我发现我需要挂钩另一个事件DetectRelatedMsiPackage
。我找到了this issue and associated code,发帖人很友善地分享了,我能够根据自己的需要进行调整,如下:
public override void OnDetectRelatedMsiPackage(WPFBootstrapperEventArgs<Wix.DetectRelatedMsiPackageEventArgs> e)
var existingPackageProductCode = e.Arguments.ProductCode;
var existingPackageId = e.Arguments.PackageId;
if (existingPackageId != HSMClientPackageID)
return;
InstallData.RelatedOperation = e.Arguments.Operation;
if (InstallData.RelatedOperation == Wix.RelatedOperation.MajorUpgrade)
//requires reference to WiX Toolset\SDK\Microsoft.Deployment.WindowsInstaller.dll
var installedPackage = new ProductInstallation(existingPackageProductCode);
if (!installedPackage.IsInstalled)
//Log(string.Format("Migrating Package 0, which is not installed, so marking it and it's features as Absent", existingPackageId));
_packageStates[existingPackageId] = Wix.PackageState.Absent;
else
//Log(string.Format("Migrating features for MajorUpgrade of Package 0", existingPackageId));
_packageStates[existingPackageId] = Wix.PackageState.Present;
foreach (var currentInstallFeature in installedPackage.Features)
switch (currentInstallFeature.State)
case InstallState.Local:
//Log(string.Format("Migrating feature 1 of Package 0 - marking as Present", existingPackageId, currentInstallFeature.FeatureName));
_featureStates[currentInstallFeature.FeatureName] = Wix.FeatureState.Local;
break;
case InstallState.Absent:
//Log(string.Format("Migrating feature 1 of Package 0 - marking as Absent", existingPackageId, currentInstallFeature.FeatureName));
_featureStates[currentInstallFeature.FeatureName] = Wix.FeatureState.Absent;
break;
default:
//Log(string.Format("Migrating feature 1 of Package 0 - marking as Unknown", existingPackageId, currentInstallFeature.FeatureName));
_featureStates[currentInstallFeature.FeatureName] = Wix.FeatureState.Unknown;
break;
【讨论】:
是的,我相信就是这样!以上是关于确定先前软件包版本的 WiX 错误的主要内容,如果未能解决你的问题,请参考以下文章