Wix Custom BA 正确处理升级

Posted

技术标签:

【中文标题】Wix Custom BA 正确处理升级【英文标题】:Wix Custom BA properly handle upgrade 【发布时间】:2015-03-02 20:48:52 【问题描述】:

几天来,我一直在使用 Wix 自定义引导程序,试图让升级正常工作。 BA 升级代码保持不变,而 MSI 文件具有新的产品代码。我只在 ARP 中显示 BA,而不是 MSI。我已经达到了正确升级所有 MSI 文件的程度,但是当它到达最后并打开旧捆绑包以卸载它时,它会打开并执行,但是 ARP 中的条目仍然存在,所以现在我有了两个。

这是完整的代码(减去一些特定于 GUI 的代码):

public class MainViewModel : ViewModelBase

    public MainViewModel(BootstrapperApplication bootstrapper)
    
        isInstall = true;
        isUpgrade = false;
        isOldBundle = false;
        userHasCancelled = false;
        encounteredError = false;
        ExitEnabled = true;
        installedArchitecture = "";

        this.Bootstrapper = bootstrapper;

        //Add listeners to all the events here

        Command command = bootstrapper.Command;
        if (command.Action == LaunchAction.Uninstall) 
            isInstall = false;
            if (command.Display == Display.Embedded) 
                isOldBundle = true;
            
        

        if (!isOldBundle) 
            Messenger.Default.Register<SwitchViewMessage>(this, (switchViewMessage) =>
            
                SwitchView(switchViewMessage.ViewName);
            );

            SwitchView("Install");
        
    

    private bool install64Bit()
    
        return optionsDataContext.SelectedArchitecture == 0;
    

    private bool isInstall;
    private bool isUpgrade;
    private bool userHasCancelled;
    private bool encounteredError;

    public BootstrapperApplication Bootstrapper  get; private set; 

    private void OptionsExecute()
    
        SwitchView("Options");
    

    private void InstallExecute()
    
        if (FrameView == optionsView) 
            //Ok pressed in Options View
            optionsDataContext.StoreLastInstallLocation();
            SwitchView("Install");
         else if (installDataContext.AcceptLicense)                 
            Bootstrapper.Engine.StringVariables["InstallFolder"] = optionsDataContext.InstallLocation;

            Bootstrapper.Engine.Plan(LaunchAction.Install);
            SwitchView("Progress");
         else 
            TopMostMessageBox.Show("You must accept the License Agreement.", "Error");
        
    

    private void UninstallExecute()
    
        Bootstrapper.Engine.Plan(LaunchAction.Uninstall);
        SwitchView("Progress");
    

    private void ExitExecute()
    
        if (FrameView == optionsView) 
            //Cancel pressed in Options View
            optionsDataContext.RestoreLastInstallLocation();
            SwitchView("Install");
         else if (FrameView == progressView) 
            //Cancel mid installation
            userHasCancelled = true;
            this.ExitEnabled = false;
            SwitchView("Complete");
         else 
            if (FrameView == completeView) 
                if (!userHasCancelled && !encounteredError && isInstall && completeDataContext.LaunchApplication) 
                    string exePath = optionsDataContext.InstallLocation + "\\program\\flexsim.exe";
                    ProcessStartInfo exeFile = new ProcessStartInfo(exePath);
                    Process.Start(exeFile);
                
            
            FlexSimBootstrapper.BootstrapperDispatcher.InvokeShutdown();
        
    

    private void OnApplyComplete(object sender, ApplyCompleteEventArgs e)
    
        OptionsEnabled = false;
        InstallEnabled = false;
        UninstallEnabled = false;
        if (e.Status < 0) 
            userHasCancelled = true;
            SwitchView("Complete");
        
    

    private string installedArchitecture;

    private void OnDetectPackageComplete(object sender, DetectPackageCompleteEventArgs e)
    
        if (isOldBundle)  //Don't do anything with packages, we're just uninstalling the bundle
            return;
        
        if (e.PackageId.StartsWith("FlexSim")) 
            if (!isInstall) 
                //If we're being upgraded, the packages were already upgraded

             else 
                if (e.State == PackageState.Absent) 
                    if (installedArchitecture.Length > 0)
                        return;
                    OptionsEnabled = true;
                    isInstall = true;
                    this.InstallEnabled = true; //Update the InstallView
                 else if (e.State == PackageState.Present) 
                    installedArchitecture = e.PackageId.Substring(e.PackageId.Length - 3, 3);
                    isInstall = false;
                    this.InstallEnabled = false; //Update the InstallView
                    UninstallEnabled = true;
                
            
         else 
            string architecture = (install64Bit() ? "x64" : "x86");
            if (installedArchitecture.Length > 0)
                architecture = installedArchitecture;

            if (isInstall) 
                //If this is a bug fix release, check to see which modules are already installed and
                //whether there are modules to be updated
                if (e.PackageId == ("Conveyor_" + architecture)) 
                    if (e.State == PackageState.Present) 
                        installDataContext.ConveyorEnabled = false;
                     else 
                        installDataContext.InstallConveyor = true;
                    
                 else if (e.PackageId == ("AGV_" + architecture)) 
                    if (e.State == PackageState.Present) 
                        installDataContext.AGVEnabled = false;
                     else 
                        installDataContext.InstallAGV = true;
                    
                 else if (e.PackageId == ("AStar_" + architecture)) 
                    if (e.State == PackageState.Present) 
                        installDataContext.AStarEnabled = false;
                     else 
                        installDataContext.InstallAStar = true;
                    
                
             else 
                  //Check to see which modules were installed and only show those checkboxes
                if (e.PackageId == ("Conveyor_" + architecture)) 
                    if (e.State == PackageState.Absent) 
                        installDataContext.ConveyorEnabled = false;
                     else 
                        installDataContext.InstallConveyor = true;
                    
                 else if (e.PackageId == ("AGV_" + architecture)) 
                    if (e.State == PackageState.Absent) 
                        installDataContext.AGVEnabled = false;
                     else 
                        installDataContext.InstallAGV = true;
                    
                 else if (e.PackageId == ("AStar_" + architecture)) 
                    if (e.State == PackageState.Absent) 
                        installDataContext.AStarEnabled = false;
                     else 
                        installDataContext.InstallAStar = true;
                    
                
            
        
    

    private void OnPlanPackageBegin(object sender, PlanPackageBeginEventArgs e)
    
        if (isOldBundle)  //Don't do anything with packages, we're just uninstalling the bundle
            return;
        
        string architecture = install64Bit() ? "x64" : "x86";
        if (e.PackageId.StartsWith("Conveyor")) 
            bool installConveyor = installDataContext.InstallConveyor && installDataContext.ConveyorEnabled && e.PackageId.EndsWith(architecture);
            e.State = installConveyor ? (isInstall ? RequestState.Present : RequestState.Absent) : RequestState.None;
         else if (e.PackageId.StartsWith("AGV")) 
            bool installAGV = installDataContext.InstallAGV && installDataContext.AGVEnabled && e.PackageId.EndsWith(architecture);
            e.State = installAGV ? (isInstall ? RequestState.Present : RequestState.Absent) : RequestState.None;
         else if (e.PackageId.StartsWith("AStar")) 
            bool installAStar = installDataContext.InstallAStar && installDataContext.AStarEnabled && e.PackageId.EndsWith(architecture);
            e.State = installAStar ? (isInstall ? RequestState.Present : RequestState.Absent) : RequestState.None;
         else if (e.PackageId.StartsWith("FlexSim")) 
            e.State = e.PackageId.EndsWith(architecture) ? (isInstall ? RequestState.Present : RequestState.Absent) : RequestState.None;
        
    

    private void OnPlanComplete(object sender, PlanCompleteEventArgs e)
    
        if (e.Status >= 0)
            Bootstrapper.Engine.Apply(System.IntPtr.Zero);
    

    private void OnExecuteMsiMessage(object sender, ExecuteMsiMessageEventArgs e)
    
        if (e.MessageType == InstallMessage.ActionStart) 
            string text = e.Message.Split(' ')[2];
            text = text.TrimEnd('.');

            //Turn the camel case text into a more readable format
            var r = new Regex(@"
             (?<=[A-Z])(?=[A-Z][a-z]) |
             (?<=[^A-Z])(?=[A-Z]) |
             (?<=[A-Za-z])(?=[^A-Za-z])", RegexOptions.IgnorePatternWhitespace);

            progressDataContext.ProgressText = r.Replace(text, " ");
        
    

    private void OnProgress(object sender, ProgressEventArgs e)
    
        progressDataContext.ProgressPercent = e.OverallPercentage;

        // handle user cancellations here
        if (userHasCancelled)
            e.Result = Result.Cancel;
    

    private void OnExecuteProgress(object sender, ExecuteProgressEventArgs e)
    
        progressDataContext.ProgressPercent = e.ProgressPercentage;

        if (userHasCancelled)
            e.Result = Result.Cancel;
    

    private void OnCacheAcquireProgress(object sender, CacheAcquireProgressEventArgs e)
    
        progressDataContext.ProgressPercent = e.OverallPercentage;
        string packageName = e.PackageOrContainerId.Substring(0, e.PackageOrContainerId.Length - 4); //Remove architecture
        progressDataContext.ProgressText = "Downloading " + packageName + (packageName == "FlexSim" ? "" : "Module");

        if (userHasCancelled)
            e.Result = Result.Cancel;
    

    private void OnCacheAcquireBegin(object sender, CacheAcquireBeginEventArgs e)
    
        progressDataContext.ProgressPercent = 0;
        string packageName = e.PackageOrContainerId.Substring(0, e.PackageOrContainerId.Length - 4); //Remove architecture
        progressDataContext.ProgressText = "Beginning download of " + packageName + (packageName == "FlexSim" ? "" : "Module");
    

    private void OnCacheAcquireComplete(object sender, CacheAcquireCompleteEventArgs e)
    
        progressDataContext.ProgressPercent = 100; 
        string packageName = e.PackageOrContainerId.Substring(0, e.PackageOrContainerId.Length - 4); //Remove architecture
        progressDataContext.ProgressText = "Download of " + packageName + (packageName == "FlexSim" ? "" : "Module") + " Complete";
    

    private void OnCacheComplete(object sender, CacheCompleteEventArgs e)
    
        progressDataContext.ProgressPercent = 100;
        progressDataContext.PackageName = "Download Complete";
        progressDataContext.ProgressText = "";
    

    private void OnError(object sender, ErrorEventArgs e)
    
        string packageName = e.PackageId.Substring(0, e.PackageId.Length - 4); //Remove architecture
        if (e.PackageId == "Netfx4Full")
            packageName = ".NET 4.0";
        TopMostMessageBox.Show(e.ErrorMessage, "Error " + (isUpgrade ? "Upgrading" : (isInstall ? "Installing" : "Uninstalling")) + " " + packageName);
        if (packageName == "FlexSim" || packageName == ".NET 4.0")
            encounteredError = true; //Rollback
    

    private void OnExecuteFilesInUse(object sender, ExecuteFilesInUseEventArgs e)
    
        string packageName = e.PackageId.Substring(0, e.PackageId.Length - 4); //Remove architecture
        if (e.PackageId == "Netfx4Full")
            packageName = ".NET 4.0";
        DialogResult result = TopMostMessageBox.Show("Unable to continue installation, files are in use. Please close FlexSim before continuing.", "Error " + (isInstall ? "Installing" : "Uninstalling") + " " + packageName, MessageBoxButtons.RetryCancel);
        if (result == DialogResult.Cancel)
            encounteredError = true; //Rollback
    

    private void OnExecutePackageBegin(object sender, ExecutePackageBeginEventArgs e)
    
        progressDataContext.ProgressPercent = 0;
        string packageName = e.PackageId.Substring(0, e.PackageId.Length - 4); //Remove architecture
        Guid relatedBundle;
        if (Guid.TryParse(e.PackageId.Substring(1, e.PackageId.Length - 2), out relatedBundle)) 
            progressDataContext.PackageName = "Cleaning Up...";
            progressDataContext.ProgressText = "";
         else 
            progressDataContext.PackageName = (isUpgrade ? "Upgrading" : (isInstall ? "Installing" : "Uninstalling")) + " " + packageName + "...";
            progressDataContext.ProgressText = "Opening package";
        
    

    private void OnExecutePackageComplete(object sender, ExecutePackageCompleteEventArgs e)
    
        progressDataContext.ProgressPercent = 100;
    

   private void OnExecuteComplete(object sender, ExecuteCompleteEventArgs e)
    
        if (isUpgrade && !isInstall) 
            //Uninstalling the old bootstrapper
            Bootstrapper.Engine.Quit(0);
            Environment.Exit(0);
            return;
        

        SwitchView("Complete");
    

   private void OnResolveSource(object sender, ResolveSourceEventArgs e)
   
       string architecture = install64Bit() ? "x64" : "x86";
       if (!string.IsNullOrEmpty(e.DownloadSource) && e.PackageOrContainerId.EndsWith(architecture))
       
           e.Result = Result.Download;

           progressDataContext.PackageName = "Please wait, downloading installation files...";
           progressDataContext.ProgressText = "Contacting server";
       
   

   private void OnDetectRelatedBundle(object sender, DetectRelatedBundleEventArgs e)
   
       if (e.Version.ToString() == "7.5.0.0") 
           TopMostMessageBox.Show("Please uninstall FlexSim 7.5.0 before running this installer.", "Error");
           Environment.Exit(0);
        else 
           isUpgrade = true;
           if (Bootstrapper.Command.Display == Display.Embedded) 
               //This bootstrapper is being run after FlexSim was upgraded in order to remove it from the ARP
               Bootstrapper.Engine.Plan(LaunchAction.Uninstall);
            else 
               installDataContext.IsUpgrade = true;
               this.AppName = getFullProductName() + " Upgrade";
               this.InstallName = "Upgrade";
           
       
   

这是升级包的日志:

Burn v3.9.1006.0, Windows v6.2 (Build 9200: Service Pack 0), path: \\hulk\Temp\Matt Long\FlexSim7.5.4\FlexSimInstaller.exe, cmdline: ''
Setting string variable 'WixBundleLog' to value 'C:\Users\DEVELO~1\AppData\Local\Temp\FlexSim_7.5.4_20150303100732.log'
Setting string variable 'WixBundleOriginalSource' to value '\\hulk\Temp\Matt Long\FlexSim7.5.4\FlexSimInstaller.exe'
Setting string variable 'WixBundleOriginalSourceFolder' to value '\\hulk\Temp\Matt Long\FlexSim7.5.4\'
Setting string variable 'WixBundleName' to value 'FlexSim 7.5.4'
Loading managed bootstrapper application.
Creating BA thread to run asynchronously.
Launching FlexSimBootstrapper UX
Detect begin, 9 packages
Setting string variable 'Netfx4x64FullVersion' to value '4.5.50709'
Setting string variable 'Netfx4FullVersion' to value '4.5.50709'
Detected related bundle: c2bb38d9-e545-4dee-a6e6-2e483f088a7a, type: Upgrade, scope: PerMachine, version: 7.5.2.0, operation: MajorUpgrade
Condition 'Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)' evaluates to true.
Detected related package: 65565599-386F-4A2A-B63E-88A873AE8AB8, scope: PerMachine, version: 7.5.2.0, language: 0 operation: MajorUpgrade
Detected related package: 65565599-386F-4A2A-B63E-88A873AE8AB8, scope: PerMachine, version: 7.5.2.0, language: 0 operation: MajorUpgrade
Detected related package: 65565599-386F-4A2A-B63E-88A873AE8AB8, scope: PerMachine, version: 7.5.2.0, language: 0 operation: MajorUpgrade
Detected related package: 65565599-386F-4A2A-B63E-88A873AE8AB8, scope: PerMachine, version: 7.5.2.0, language: 0 operation: MajorUpgrade
Detected package: Netfx4Full, state: Present, cached: None
Detected package: FlexSim_x86, state: Absent, cached: None
Detected package: FlexSim_x64, state: Absent, cached: None
Detected package: Conveyor_x86, state: Absent, cached: None
Detected package: AGV_x86, state: Absent, cached: None
Detected package: AStar_x86, state: Absent, cached: None
Detected package: Conveyor_x64, state: Absent, cached: None
Detected package: AGV_x64, state: Absent, cached: None
Detected package: AStar_x64, state: Absent, cached: None
Detect complete, result: 0x0
Setting string variable 'InstallFolder' to value 'C:\Program Files\FlexSim7.5'
Plan begin, 9 packages, action: Install
Condition '(VersionNT < v6.0 OR VersionNT64 < v6.0) AND (NOT (Net4FullVersion OR Net4x64FullVersion))' evaluates to false.
Skipping dependency registration on package with no dependency providers: Netfx4Full
Setting string variable 'WixBundleRollbackLog_FlexSim_x64' to value 'C:\Users\DEVELO~1\AppData\Local\Temp\FlexSim_7.5.4_20150303100732_0_FlexSim_x64_rollback.log'
Setting string variable 'WixBundleLog_FlexSim_x64' to value 'C:\Users\DEVELO~1\AppData\Local\Temp\FlexSim_7.5.4_20150303100732_0_FlexSim_x64.log'
Condition 'NOT Installed' evaluates to true.
Condition 'NOT Installed' evaluates to true.
Condition 'NOT Installed' evaluates to true.
Condition 'NOT Installed' evaluates to true.
Condition 'NOT Installed' evaluates to true.
Condition 'NOT Installed' evaluates to true.
Planned package: Netfx4Full, state: Present, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
Planned package: FlexSim_x86, state: Absent, default requested: Present, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: None
Planned package: FlexSim_x64, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register
Planned package: Conveyor_x86, state: Absent, default requested: Present, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: None
Planned package: AGV_x86, state: Absent, default requested: Present, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: None
Planned package: AStar_x86, state: Absent, default requested: Present, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: None
Planned package: Conveyor_x64, state: Absent, default requested: Present, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: None
Planned package: AGV_x64, state: Absent, default requested: Present, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: None
Planned package: AStar_x64, state: Absent, default requested: Present, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: None
Planned related bundle: c2bb38d9-e545-4dee-a6e6-2e483f088a7a, type: Upgrade, default requested: Absent, ba requested: Absent, execute: Uninstall, rollback: Install, dependency: None
Plan complete, result: 0x0
Apply begin
Creating a system restore point.
Created a system restore point.
Caching bundle from: 'C:\Users\DEVELO~1\AppData\Local\Temp\67225db2-d963-4067-ba1b-f42a8f1f6dcb\.be\FlexSimInstaller.exe' to: 'C:\ProgramData\Package Cache\67225db2-d963-4067-ba1b-f42a8f1f6dcb\FlexSimInstaller.exe'
Registering bundle dependency provider: 67225db2-d963-4067-ba1b-f42a8f1f6dcb, version: 7.5.4.0
Acquiring package: FlexSim_x64, payload: FlexSim_x64, copy from: \\hulk\Temp\Matt Long\FlexSim7.5.4\flexsim__7.5.4._x64
Setting string variable 'WixBundleLastUsedSource' to value '\\hulk\Temp\Matt Long\FlexSim7.5.4\'
Verified acquired payload: FlexSim_x64 at path: C:\ProgramData\Package Cache\.unverified\FlexSim_x64, moving to: C:\ProgramData\Package Cache\DE2D8A1C-DD4A-411C-A23B-A9C0943AFC84v7.5.4\flexsim__7.5.4._x64.
Registering package dependency provider: DE2D8A1C-DD4A-411C-A23B-A9C0943AFC84, version: 7.5.4, package: FlexSim_x64
Applying execute package: FlexSim_x64, action: Install, path: C:\ProgramData\Package Cache\DE2D8A1C-DD4A-411C-A23B-A9C0943AFC84v7.5.4\flexsim__7.5.4._x64, arguments: ' ARPSYSTEMCOMPONENT="1" MSIFASTINSTALL="7" INSTALLDIR="C:\Program Files\FlexSim7.5"'
Applied execute package: FlexSim_x64, result: 0x0, restart: None
Registering dependency: 67225db2-d963-4067-ba1b-f42a8f1f6dcb on package provider: DE2D8A1C-DD4A-411C-A23B-A9C0943AFC84, package: FlexSim_x64
Applying execute package: c2bb38d9-e545-4dee-a6e6-2e483f088a7a, action: Uninstall, path: C:\ProgramData\Package Cache\c2bb38d9-e545-4dee-a6e6-2e483f088a7a\FlexSimInstaller.exe, arguments: '"C:\ProgramData\Package Cache\c2bb38d9-e545-4dee-a6e6-2e483f088a7a\FlexSimInstaller.exe" -uninstall -quiet -burn.related.upgrade -burn.ancestors=67225db2-d963-4067-ba1b-f42a8f1f6dcb'
Applied execute package: c2bb38d9-e545-4dee-a6e6-2e483f088a7a, result: 0x0, restart: None
Apply complete, result: 0x0, restart: None, ba requested restart:  No
Shutting down, exit code: 0x0
Variable: InstallFolder = C:\Program Files\FlexSim7.5
Netfx4FullVersion = 4.5.50709
Netfx4x64FullVersion = 4.5.50709
VersionNT = 6.2.0.0
VersionNT64 = 6.2.0.0
Variable:WixBundleAction = 4
Variable: WixBundleElevated = 1
Variable: WixBundleLastUsedSource = \\hulk\Temp\Matt Long\FlexSim7.5.4\
Variable: WixBundleLog = C:\Users\DEVELO~1\AppData\Local\Temp\FlexSim_7.5.4_20150303100732.log
Variable: WixBundleLog_FlexSim_x64 = C:\Users\DEVELO~1\AppData\Local\Temp\FlexSim_7.5.4_20150303100732_0_FlexSim_x64.log
Variable: WixBundleManufacturer = FlexSim Software Products, Inc.
Variable: WixBundleName = FlexSim 7.5.4
Variable: WixBundleOriginalSource = \\hulk\Temp\Matt Long\FlexSim7.5.4\FlexSimInstaller.exe
Variable: WixBundleOriginalSourceFolder = \\hulk\Temp\Matt Long\FlexSim7.5.4\
Variable: WixBundleProviderKey = 67225db2-d963-4067-ba1b-f42a8f1f6dcb
Variable: WixBundleRollbackLog_FlexSim_x64 = C:\Users\DEVELO~1\AppData\Local\Temp\FlexSim_7.5.4_20150303100732_0_FlexSim_x64_rollback.log
Variable: WixBundleTag = FlexSim
Variable: WixBundleVersion = 7.5.4.0
Exit code: 0x0, restarting: No

以及卸载旧包:

Burn v3.9.1006.0, Windows v6.2 (Build 9200: Service Pack 0), path: C:\ProgramData\Package Cache\c2bb38d9-e545-4dee-a6e6-2e483f088a7a\FlexSimInstaller.exe, cmdline: '-burn.unelevated BurnPipe.75719B82-36F8-4EEC-9627-95F9C80EFD3D C5DDF0F8-2C71-4784-918C-123444FEB511 3048 -uninstall -quiet -burn.related.upgrade -burn.ancestors=67225db2-d963-4067-ba1b-f42a8f1f6dcb -burn.embedded BurnPipe.FD72859F-485B-49ED-955A-3BE174642F7C 7C01F82A-C3C3-42F9-AF31-0E9995FB9E61 4480'
This bundle is being run by a related bundle as type 'Upgrade'.
Setting string variable 'WixBundleLog' to value 'C:\Users\DEVELO~1\AppData\Local\Temp\FlexSim_7.5.2_20150303100853.log'
Loading managed bootstrapper application.
Creating BA thread to run asynchronously.
Launching FlexSimBootstrapper UX
Detect begin, 9 packages
Setting string variable 'Netfx4x64FullVersion' to value '4.5.50709'
Setting string variable 'Netfx4FullVersion' to value '4.5.50709'
Detected related bundle: 67225db2-d963-4067-ba1b-f42a8f1f6dcb, type: Upgrade, scope: PerMachine, version: 7.5.4.0, operation: None
Condition 'Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)' evaluates to true.
Detected partially cached package: FlexSim_x86, invalid payload: FlexSim_x86, reason: 0x80070002
Detected related package: DE2D8A1C-DD4A-411C-A23B-A9C0943AFC84, scope: PerMachine, version: 7.5.4.0, language: 0 operation: Downgrade
Detected related package: DE2D8A1C-DD4A-411C-A23B-A9C0943AFC84, scope: PerMachine, version: 7.5.4.0, language: 0 operation: Downgrade
Detected package: Netfx4Full, state: Present, cached: None
Detected package: FlexSim_x86, state: Obsolete, cached: Partial
Detected package: FlexSim_x64, state: Obsolete, cached: Complete
Detected package: Conveyor_x86, state: Absent, cached: None
Detected package: AGV_x86, state: Absent, cached: None
Detected package: AStar_x86, state: Absent, cached: None
Detected package: Conveyor_x64, state: Absent, cached: None
Detected package: AGV_x64, state: Absent, cached: None
Detected package: AStar_x64, state: Absent, cached: None
Detect complete, result: 0x0
Plan begin, 9 packages, action: Uninstall
Plan skipped related bundle: 67225db2-d963-4067-ba1b-f42a8f1f6dcb, type: Upgrade, because it was previously scheduled.
Skipping dependency registration on package with no dependency providers: Netfx4Full
Planned related bundle: 67225db2-d963-4067-ba1b-f42a8f1f6dcb, type: Upgrade, default requested: None, ba requested: None, execute: None, rollback: None, dependency: None
Planned package: AStar_x64, state: Absent, default requested: Absent, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: Unregister
Planned package: AGV_x64, state: Absent, default requested: Absent, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: Unregister
Planned package: Conveyor_x64, state: Absent, default requested: Absent, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: Unregister
Planned package: AStar_x86, state: Absent, default requested: Absent, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: Unregister
Planned package: AGV_x86, state: Absent, default requested: Absent, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: Unregister
Planned package: Conveyor_x86, state: Absent, default requested: Absent, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: Unregister
Planned package: FlexSim_x64, state: Obsolete, default requested: None, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: Yes, dependency: Unregister
Planned package: FlexSim_x86, state: Obsolete, default requested: None, ba requested: None, execute: None, rollback: None, cache: No, uncache: Yes, dependency: Unregister
Planned package: Netfx4Full, state: Present, default requested: None, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: None
Plan complete, result: 0x0
Apply begin
Removed package dependency provider: 124DDD12-0BD0-464E-B753-4BC53D27770A, package: AStar_x64
Removed package dependency provider: E48B3FBD-001F-4D1F-876B-B041044B6B87, package: AGV_x64
Removed package dependency provider: 65E44AB7-FBC5-480A-92B5-519CF57F6CDD, package: Conveyor_x64
Removed package dependency provider: 124DDD12-0BD0-464E-B753-4BC53D27770A, package: AStar_x86
Removed package dependency provider: E48B3FBD-001F-4D1F-876B-B041044B6B87, package: AGV_x86
Removed package dependency provider: 65E44AB7-FBC5-480A-92B5-519CF57F6CDD, package: Conveyor_x86
Removed dependency: c2bb38d9-e545-4dee-a6e6-2e483f088a7a on package provider: 65565599-386F-4A2A-B63E-88A873AE8AB8, package FlexSim_x64

【问题讨论】:

一切看起来都不错,只是卸载日志显示不完整。如果这真的是整个日志,那么它似乎在完成应用之前就崩溃了,希望应用程序事件日志中有错误。 【参考方案1】:

我终于明白了!正如怀疑它是小东西。一切都与时机有关。

第一个问题是我需要在 DetectComplete 操作中执行计划卸载:

   private void OnDetectComplete(object sender, DetectCompleteEventArgs e)
   
       if (Bootstrapper.Command.Action == LaunchAction.Uninstall && Bootstrapper.Command.Display == Display.Embedded)
       
           Bootstrapper.Engine.Plan(LaunchAction.Uninstall);
       
   

那么卸载旧捆绑包的日志被缩短的原因是由于我过早地退出了应用程序。我将其移至 ApplyComplete 操作:

    private void OnApplyComplete(object sender, ApplyCompleteEventArgs e)
    
        if (Bootstrapper.Command.Action == LaunchAction.Uninstall && Bootstrapper.Command.Display == Display.Embedded) 
            //Uninstalling the old bootstrapper
            Bootstrapper.Engine.Quit(0);
            Environment.Exit(0);
        
    

【讨论】:

我忘了在我原来的答案中提到这一点:不要打电话给Environment.Exit。 BA 是这个过程中的客人,Bootstrapper.Engine.Quit 是你告诉 Burn 你已经完成的方式。 Burn 将从那里调用 ExitProcess。【参考方案2】:

Burn 过于复杂,无法仅通过精简代码进行诊断。我们需要来自正在卸载的旧包和正在安装的新包的真实代码和/或刻录日志。

您通常应该使用Command.Action 属性中的LaunchAction 来决定要采取的操作。如果你这样做,增加你的包的版本,并删除你的 On*RelatedBundle 方法,它应该可以工作。您的 OnPlanPackageBegin 方法可能也应该被删除,默认情况下,Burn 将在安装操作期间安装包,并在卸载操作期间删除包。另外,不要将e.Result 设置为Result.Error,它不会做任何事情。

【讨论】:

我已将代码更新为更完整,并包含了两个日志文件。【参考方案3】:

我有一个类似的问题,我们以前的产品安装程序是一个 Msi,现在我们有一个托管引导程序应用程序的第一个版本,其中捆绑了几个先决条件和 MSI。我们必须升级当前安装的产品。我所做的只是为 Bundle.wxs 中链中的相关 Msi 包设置 MsiProperty UPGRADE=1。

看我在Upgrade older msi from Wix custom BA Bundle的回答

【讨论】:

以上是关于Wix Custom BA 正确处理升级的主要内容,如果未能解决你的问题,请参考以下文章

WIX:在单独的 cab 文件中升级未版本控制的文件

卸载升级时如何摆脱wix中未使用的dll

处理WIX警告的正确方法:LGHT1076:ICE48

如何实现 WiX 安装程序升级?

WiX:如何防止注册表值在卸载时被删除?

如何使用 WIX 升级数据库?