在Wix设置中选择“删除”时,我已经创建了一个自定义操作来卸载VS包。
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
ActionResult result = ActionResult.Failure;
try
{
session.Log("Begin CustomAction1");
string VSIXInstallerPath = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config", "VSIXInstallerLocation", null);
Process UninstallVSPackage = new Process();
UninstallVSPackage = Process.Start(VSIXInstallerPath, "/u:GUID /quiet");
result = ActionResult.Success;
}
catch (Exception ex)
{
session.Log("ERROR in custom action {0}",
ex.ToString());
return ActionResult.Failure;
}
return result;
}
}
}
这是相关的WIX标记:
<Binary Id="UninstallVSPackageAction"
src="$(var.TargetDir)\SELA.TFS.MBWI.CustomAction1.CA.dll" />
<CustomAction Id="RemoveVsPackage" BinaryKey="UninstallVSPackageAction"
DllEntry="DeleteVSPackage" Execute="deferred" Return="check" />
<Custom Action="RemoveVsPackage" After="InstallInitialize">
Installed AND NOT UPGRADINGPRODUCTCODE
</Custom>
此操作因下一个错误日志而失败:
CustomAction RemoveVsPackage returned actual error code 1154 (note this may not be 100% accurate if translation happened inside sandbox)
MSI (s) (F8:60) [06:43:39:304]: Note: 1: 1723 2: RemoveVsPackage 3: DeleteVSPackage 4: C:\Windows\Installer\MSI1663.tmp
MSI (s) (F8:60) [06:43:39:304]: Note: 1: 2205 2: 3: Error
MSI (s) (F8:60) [06:43:39:304]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1723
Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor. Action RemoveVsPackage, entry: DeleteVSPackage, library: C:\Windows\Installer\MSI1663.tmp
MSI (s) (F8:60) [06:43:41:476]: Note: 1: 2205 2: 3: Error
MSI (s) (F8:60) [06:43:41:476]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709
MSI (s) (F8:60) [06:43:41:476]: Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor. Action RemoveVsPackage, entry: DeleteVSPackage, library: C:\Windows\Installer\MSI1663.tmp