-
Notifications
You must be signed in to change notification settings - Fork 1
ConfigViewModel Class
Richard Martin edited this page Mar 25, 2024
·
2 revisions
Bootstrapper.ViewModels.ConfigViewModel
This VM demonstrates how you could expose a bundle variable through a property. If we want to assign a value to the package's SAMPLE property, we can define a bundle variable in Bundle.wxs.
<Variable Name="SampleOption" Type="string" Value="" />
In the Chain, we can assign the value of SampleOption to SAMPLE. We declare this as a child of MsiPackage
.
<Chain>
<MsiPackage ... >
<MsiProperty Name='SAMPLE' Value='[SampleOption]'/>
</MsiPackage>
</Chain>
Finally, in ConfigVm, we can expose SampleOption through a property.
public string SampleOption
{
get
{
if (_model.Engine.ContainsVariable("SampleOption"))
return _model.Engine.GetVariableString("SampleOption");
return string.Empty;
}
set
{
_model.Engine.SetVariableString("SampleOption", value, false);
OnPropertyChanged();
}
}
Looking at the package's log after the install has run, you can find the value that was supplied by the bundle.
MSI (s) (D4:74) [10:57:30:856]: PROPERTY CHANGE: Adding SAMPLE property. Its value is 'abc'.