Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 使用inside Burn Bootstrapper项目获取应用程序版本_Wpf_Wix_Bootstrapper_Burn_Wix3.10 - Fatal编程技术网

Wpf 使用inside Burn Bootstrapper项目获取应用程序版本

Wpf 使用inside Burn Bootstrapper项目获取应用程序版本,wpf,wix,bootstrapper,burn,wix3.10,Wpf,Wix,Bootstrapper,Burn,Wix3.10,通常在Bundle.wxs文件中设置EXE版本。是否可以在编写安装程序后端引擎逻辑的引导程序应用程序项目中获得此版本?我已经使用WPF创建了一个自定义UI。我需要在UI中显示版本。我该怎么做?请给我一些建议。下面是我的引导程序应用程序代码 public class MainViewModel : ViewModelBase { private MINAClient minaClient; //constructor public

通常在Bundle.wxs文件中设置EXE版本。是否可以在编写安装程序后端引擎逻辑的引导程序应用程序项目中获得此版本?我已经使用WPF创建了一个自定义UI。我需要在UI中显示版本。我该怎么做?请给我一些建议。下面是我的引导程序应用程序代码

    public class MainViewModel : ViewModelBase
    {
        private MINAClient minaClient;

        //constructor
        public MainViewModel(BootstrapperApplication bootstrapper)
        {

            this.IsThinking = false;

            this.Bootstrapper = bootstrapper;
            this.Bootstrapper.ApplyComplete += this.OnApplyComplete;
            this.Bootstrapper.DetectPackageComplete += this.OnDetectPackageComplete;
            this.Bootstrapper.PlanComplete += this.OnPlanComplete;
            this.Bootstrapper.DetectComplete += this.DetectComplete;

            this.Bootstrapper.CacheAcquireProgress += (sender, args) =>
            {
                this.cacheProgress = args.OverallPercentage;
                this.Progress = (this.cacheProgress + this.executeProgress) / 2;
            };
            this.Bootstrapper.ExecuteProgress += (sender, args) =>
            {
                this.executeProgress = args.OverallPercentage;
                this.Progress = (this.cacheProgress + this.executeProgress) / 2;
            };

            minaClient = new MINAClient();
            minaClient.initConnection("127.0.0.1", 9123);
        }

        #region Properties

        private bool installEnabled;
        public bool InstallEnabled
        {
            get { return installEnabled; }
            set
            {
                installEnabled = value;
                RaisePropertyChanged("InstallEnabled");
            }
        }

        private bool uninstallEnabled;
        public bool UninstallEnabled
        {
            get { return uninstallEnabled; }
            set
            {
                uninstallEnabled = value;
                RaisePropertyChanged("UninstallEnabled");
            }
        }

        private bool isThinking;
        public bool IsThinking
        {
            get { return isThinking; }
            set
            {
                isThinking = value;
                RaisePropertyChanged("IsThinking");
            }
        }

        private int progress;
        public int Progress
        {
            get { return progress; }
            set
            {
                this.progress = value;
                minaClient.sendMessage(value);
                RaisePropertyChanged("Progress");
            }
        }

        private int cacheProgress;
        private int executeProgress;

        public BootstrapperApplication Bootstrapper { get; private set; }

        #endregion //Properties

        #region Methods

        public void InstallExecute()
        {
            Bootstrapper.Engine.Log(LogLevel.Verbose, "See actually i've called install method");
            IsThinking = true;
            Bootstrapper.Engine.Plan(LaunchAction.Install);
        }

        public void UninstallExecute()
        {
            Bootstrapper.Engine.Log(LogLevel.Verbose, "See actually i've called un-install method");
            IsThinking = true;
            Bootstrapper.Engine.Plan(LaunchAction.Uninstall);
        }

        public void ExitExecute()
        {
            CustomBA.BootstrapperDispatcher.InvokeShutdown();
        }


        /// <summary>
        /// Method that gets invoked when the Bootstrapper ApplyComplete event is fired.
        /// This is called after a bundle installation has completed. Make sure we updated the view.
        /// </summary>
        private void OnApplyComplete(object sender, ApplyCompleteEventArgs e)
        {
            IsThinking = false;
            InstallEnabled = false;
            UninstallEnabled = false;
            this.Progress = 100;
            ExitExecute();
        }

        void DetectComplete(object sender, DetectCompleteEventArgs e)
        {
            Bootstrapper.Engine.Log(LogLevel.Verbose,"fired! but does that give you any clue?! idiot!");
            if (LaunchAction.Uninstall == Bootstrapper.Command.Action)
            {
                Bootstrapper.Engine.Log(LogLevel.Verbose, "Invoking automatic plan for uninstall");
                Bootstrapper.Engine.Plan(LaunchAction.Uninstall);
            } 
        }

        /// <summary>
        /// Method that gets invoked when the Bootstrapper DetectPackageComplete event is fired.
        /// Checks the PackageId and sets the installation scenario. The PackageId is the ID
        /// specified in one of the package elements (msipackage, exepackage, msppackage,
        /// msupackage) in the WiX bundle.
        /// </summary>
        private void OnDetectPackageComplete(object sender, DetectPackageCompleteEventArgs e)
        {
            if (e.PackageId == "UpdaterServiceInstallerId" || e.PackageId == "MosquittoInstallerId" || e.PackageId == "AppsInstallerId")
            {
                if (e.State == PackageState.Absent)
                    InstallEnabled = true;

                else if (e.State == PackageState.Present)
                    UninstallEnabled = true;
            }
        }

        /// <summary>
        /// Method that gets invoked when the Bootstrapper PlanComplete event is fired.
        /// If the planning was successful, it instructs the Bootstrapper Engine to 
        /// install the packages.
        /// </summary>
        private void OnPlanComplete(object sender, PlanCompleteEventArgs e)
        {
            if (e.Status >= 0)
                Bootstrapper.Engine.Apply(System.IntPtr.Zero);
        }


        #endregion //Methods

        #region RelayCommands

        private RelayCommand installCommand;
        public RelayCommand InstallCommand
        {
            get
            {
                if (installCommand == null)
                    installCommand = new RelayCommand(() => InstallExecute(), () => InstallEnabled == true);

                return installCommand;
            }
        }

        private RelayCommand uninstallCommand;
        public RelayCommand UninstallCommand
        {
            get
            {
                if (uninstallCommand == null)
                    uninstallCommand = new RelayCommand(() => UninstallExecute(), () => UninstallEnabled == true);

                return uninstallCommand;
            }
        }

        private RelayCommand exitCommand;
        public RelayCommand ExitCommand
        {
            get
            {
                if (exitCommand == null)
                    exitCommand = new RelayCommand(() => ExitExecute());

                return exitCommand;
            }
        }

        #endregion //RelayCommands
    }
public类MainViewModel:ViewModelBase
{
私人客户;
//建造师
公共主视图模型(引导程序应用程序引导程序)
{
this.IsThinking=false;
this.Bootstrapper=Bootstrapper;
this.Bootstrapper.ApplyComplete+=this.OnApplyComplete;
this.Bootstrapper.DetectPackageComplete+=this.OnDetectPackageComplete;
this.Bootstrapper.PlanComplete+=this.OnPlanComplete;
this.Bootstrapper.DetectComplete+=this.DetectComplete;
this.Bootstrapper.CacheAcquireProgress+=(发送方,参数)=>
{
this.cacheProgress=args.OverallPercentage;
this.Progress=(this.cacheProgress+this.executeProgress)/2;
};
this.Bootstrapper.ExecuteProgress+=(发送方,args)=>
{
this.executeProgress=args.OverallPercentage;
this.Progress=(this.cacheProgress+this.executeProgress)/2;
};
minaClient=新的minaClient();
minaClient.initConnection(“127.0.0.1”,9123);
}
#区域属性
私有bool;
公共bool已启用
{
获取{return installEnabled;}
设置
{
installEnabled=值;
RaisePropertyChanged(“InstallEnabled”);
}
}
启用私有bool卸载;
公共bool已启用
{
获取{return uninstallEnabled;}
设置
{
卸载启用=值;
RaisePropertyChanged(“卸载启用”);
}
}
私人布尔在思考;
公众在思考
{
获取{return is thinking;}
设置
{
i思考=价值;
RaisePropertyChanged(“IsThinking”);
}
}
私人投资进展;
公共信息技术进步
{
获取{返回进度;}
设置
{
这个。进步=价值;
minaClient.sendMessage(值);
RaiseProperty变更(“进度”);
}
}
私营部门的进展;
私有int executeProgress;
公共引导程序应用程序引导程序{get;private set;}
#endregion//属性
#区域方法
public void InstallExecute()
{
Log(LogLevel.Verbose,“请看我实际上调用了安装方法”);
IsThinking=正确;
Bootstrapper.Engine.Plan(LaunchAction.Install);
}
public-void-UninstallExecute()
{
Log(LogLevel.Verbose,“实际上我调用了uninstall方法”);
IsThinking=正确;
Bootstrapper.Engine.Plan(LaunchAction.Uninstall);
}
公共无效ExitExecute()
{
bootstrapperdDispatcher.InvokeShutdown();
}
/// 
///方法,该方法在启动引导程序ApplyComplete事件时调用。
///在捆绑包安装完成后调用。请确保更新了视图。
/// 
ApplyComplete上的私有无效(对象发送方,ApplyCompleteEventArgs e)
{
i思考=错误;
InstallEnabled=false;
UninstallEnabled=false;
这个。进度=100;
ExitExecute();
}
void DetectComplete(对象发送器,detectCompleteteEventArgs e)
{
Bootstrapper.Engine.Log(LogLevel.Verbose,“被解雇了!但这能给你任何线索吗?!白痴!”);
if(LaunchAction.Uninstall==Bootstrapper.Command.Action)
{
Bootstrapper.Engine.Log(LogLevel.Verbose,“调用自动卸载计划”);
Bootstrapper.Engine.Plan(LaunchAction.Uninstall);
} 
}
/// 
///方法,该方法在启动引导程序DetectPackageComplete事件时调用。
///检查PackageId并设置安装方案。PackageId是ID
///在包元素之一(msipackage、exepackage、msppackage、,
///WiX包中的msuppackage)。
/// 
私有void OnDetectPackageComplete(对象发送方,DetectPackageCompleteEventTarget e)
{
如果(e.PackageId==“UpdaterServiceInstallerId”| | e.PackageId==“MosQuitToInInstallerId”| | e.PackageId==“AppsInstallerId”)
{
if(e.State==PackageState.缺席)
InstallEnabled=true;
else if(e.State==PackageState.Present)
卸载启用=真;
}
}
/// 
///方法,该方法在启动引导程序PlanComplete事件时调用。
///如果计划成功,它将指示引导程序引擎
///安装软件包。
/// 
PlanComplete上的专用void(对象发送方,PlanCompleteTeeventargs e)
{
如果(如状态>=0)
Bootstrapper.Engine.Apply(System.IntPtr.Zero);
}
#endregion//方法
#区域中继命令
专用RelayCommand installCommand;
公共RelayCommand InstallCommand
{
得到
{
如果(installCommand==null)
installCommand=newre
var bundleVersion = Bootstrapper.Engine.VersionVariables["WixBundleVersion"];