2014-12-04 71 views
0

有一个WPF设置应用程序。我有TextBox绑定到我的ViewModel中的属性ProductCode更改托管引导程序(wpf)中的属性(msi)?

如何使包在.msi项目中设置为“DEF”属性?

我的代码:

WPF:

private void InstallExecute() 
     { 
      InstallEnabled = false; 
      Bootstrapper.Engine.StringVariables["ABC"] = "zyx"; 
      MainWindowViewModel.PlanAction(LaunchAction.Install); 
     } 

引导程序:

<Variable Name="ABC" bal:Overridable="yes" /> 

<MsiProperty Name="DEF" Value="[ABC]"/> 

.MSI:

<Property Id="DEF" /> 

项目与行动:

var test = session["DEF"].ToString(); //always gives empty string 

回答

1

你需要指定MsiProperty这样你的包里面:

<MsiPackage Id='MyApp' Description='My Application' SourceFile="$(var.SetupMyApp.TargetPath)"> 
    <MsiProperty Name="INSTALLFOLDER" Value="[MyAppInstallLocation]"/> 
</MsiPackage> 

添加烧伤变量它,也是在包:

<Variable bal:Overridable="yes" Name="MyAppInstallLocation" Value=""/> 

然后

Bootstrapper.Engine.StringVariables["MyAppInstallLocation"] = "C:\MyApp"; 

在启动程序中的某处,显然是在开始安装之前。