Re: [WiX-users] Passing Variables from C# custom BA to WIX
I purchased the book WIX 3.6: A Developer's Guide to Windows Installer XML. In chapter 16 it explains, step by step, how to pass variables to the WIX XML from a custom BA. In the example they are using bindings for setting the variable but in my custom BA I set them in C# code. -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113p7596305.html Sent from the wix-users mailing list archive at Nabble.com. -- ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users
Re: [WiX-users] Passing Variables from C# custom BA to WIX
Ok, I ran the debugger and to my surprise, this executes after U click the InstallA button. I was thought this would run before any buttons were clicked. So, in trying to better understand how passing parameters work, what command can I use to pass variables from my wpf application to my WIX script? Is there an example of syntax structure between C# and WIX? I would like add to my MsiPackage (in WIX) the element InstallCondition and pass a parameter to it that will either install or not install the package. Thanks Again. -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113p7596183.html Sent from the wix-users mailing list archive at Nabble.com. -- Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users
Re: [WiX-users] Passing Variables from C# custom BA to WIX
In the Bundle element, or a referenced fragment, use a Variable element and use Override='yes' Variable Name='VariableName' Value='*' Type='string' bal:Overridable='yes'/ or Variable Name='VariableName' Value='*' Type='numeric' bal:Overridable='yes'/ For control logic in InstallCondition I prefer numeric, but if the variable is to be passed to MsiProperty use a string. In the mba, in OnDetectComplete (or wherever you want after Burn initializes the variables) if (myapp.Model.Engine.StringVariables.Contains(VariableName) e.PackageId.Equals(myapp.Model.Engine.StringVariables[VariableName], StringComparison.Ordinal)) { myapp.Model.Engine.StringVariables[VariableName] = some string; } (or use Engine.NumericVariables In installCondition'= VariableName = 1 (if numeric or use quotes around a string). -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113p7596187.html Sent from the wix-users mailing list archive at Nabble.com. -- Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users
Re: [WiX-users] Passing Variables from C# custom BA to WIX
In regard to the above discussion about your mba code, I was recently looking at similar code in the wix src\Setup\WixBA\InstallViewModel.cs which has the following code: private void PlanPackageBegin(object sender, PlanPackageBeginEventArgs e) { if (WixBA.Model.Engine.StringVariables.Contains(MbaNetfxPackageId) e.PackageId.Equals(WixBA.Model.Engine.StringVariables[MbaNetfxPackageId], StringComparison.Ordinal)) { e.State = RequestState.None; } } So if you had code like this in your mba, I then: 1) Added as the first item in my Chain. PackageGroupRef Id=NetFx40ClientWeb / I did not author the PackageGroupRef but used what is in the wixNetExtension 2) Added a MbaNetfxPackageId WixVariable, and did not author the following WixVariable Id=WixMbaPrereqPackageId Value=Netfx4Full / WixVariable Id=WixMbaPrereqLicenseUrl Value=NetfxLicense.rtf / When I had the above in the wix file I got a duplicate Id error. So I have: WixVariable Id=MbaPrereqPackageId Value=NetFx40ClientWeb / This seems to be working for me. I had been meaning to sort out this issue as QA raised questions about it yesterday. Thanks to your post I was able to get it working. I still have some testing to do so maybe I am overlooking something. -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113p7596192.html Sent from the wix-users mailing list archive at Nabble.com. -- Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users
Re: [WiX-users] Passing Variables from C# custom BA to WIX
When I say that it 'worked' I mean on a Windows 8 x64, with build in netfx4x support, the mba runs and NetFx40 setup is not launched. On Windows 7 x6x with no NetFx support installed, the mba prereq dialog prompts the user to allow NetFx to be installed, then it is installed and my mba is then launched. Thanks again for the info that helped me get this working in my mba. I was always confused by examples that initialized: WixVariable Id=WixMbaPrereqPackageId Value=Netfx4Full / WixVariable Id=WixMbaPrereqLicenseUrl Value=NetfxLicense.rtf / but, when I do not do that and use the following it seems to work. More testing is needed. WixVariable Id=MbaPrereqPackageId Value=NetFx40ClientWeb / -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113p7596193.html Sent from the wix-users mailing list archive at Nabble.com. -- Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users
Re: [WiX-users] Passing Variables from C# custom BA to WIX
I also removed: WixVariable Id=MbaPrereqPackageId Value=NetFx40ClientWeb / And it seems to work without running NetFx on a system that has Fx support. But I need to test this more next week. -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113p7596194.html Sent from the wix-users mailing list archive at Nabble.com. -- Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users
Re: [WiX-users] Passing Variables from C# custom BA to WIX
Hi Rob, Thank You for the insight on using PlanPackageBegin event. I tried your recommendation in my wpf app, but haven't had much success. I have a simple wix ba project that contains one bundle and chain element. In my PlanPackageBegin event I have added source code to check for Netfx4Full. The problem here is that my PlanPackageBegin operation is never called. Although it has been subscribed to an event in my constructor. Where did I go wrong here in my implementation. I've added code for reference below: Wix Code: ?xml version=1.0 encoding=UTF-8? Wix xmlns=http://schemas.microsoft.com/wix/2006/wi; xmlns:util=http://schemas.microsoft.com/wix/UtilExtension; xmlns:bal=http://schemas.microsoft.com/wix/BalExtension; Bundle Name=My Test Application Version=1.0.0.0 Manufacturer=lino UpgradeCode=C82A383C-751A-43B8-90BF-A250F7BC2863 Variable Name =AToInstall bal:Overridable=yes Value=A Type=string/ BootstrapperApplicationRef Id=ManagedBootstrapperApplicationHost Payload SourceFile=..\TestBA\BootstrapperCore.config/ Payload SourceFile=..\TestBA\bin\Debug\TestBA.dll/ Payload SourceFile=..\TestBA\bin\Debug\GalaSoft.MvvmLight.WPF4.dll/ Payload SourceFile=C:\Program Files (x86)\WiX Toolset v3.8\SDK\Microsoft.Deployment.WindowsInstaller.dll/ /BootstrapperApplicationRef Chain PackageGroupRef Id='Netfx4Full' / MsiPackage Id=DummyInstallationPackageId SourceFile=..\DummyInstaller\bin\Release\DummyInstaller.msi Cache=yes Visible=no/ /Chain /Bundle Fragment WixVariable Id=WixMbaPrereqPackageId Value=Netfx4Full / WixVariable Id=WixMbaPrereqLicenseUrl Value=NetfxLicense.rtf / util:RegistrySearch Root=HKLM Key=SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full Value=Version Variable=Netfx4FullVersion / util:RegistrySearch Root=HKLM Key=SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full Value=Version Variable=Netfx4x64FullVersion Win64=yes / PackageGroup Id=Netfx4Full ExePackage Id=Netfx4Full Cache=no Compressed=yes PerMachine=yes Permanent=yes Vital=yes SourceFile=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40\dotNetFx40_Full_x86_x64.exe DownloadUrl=http://go.microsoft.com/fwlink/?LinkId=164193; DetectCondition=Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion) / /PackageGroup /Fragment /Wix C# wpf MainViewModel code: using Microsoft.Tools.WindowsInstallerXml.Bootstrapper; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using System; namespace Examples.Bootstrapper { public class MainViewModel : ViewModelBase { //constructor public MainViewModel(BootstrapperApplication bootstrapper) { System.Threading.Thread.Sleep(1); this.IsThinking = false; this.Bootstrapper = bootstrapper; this.Bootstrapper.ApplyComplete += this.OnApplyComplete; this.Bootstrapper.DetectPackageComplete += this.OnDetectPackageComplete; this.Bootstrapper.PlanPackageBegin += this.PlanPackageBegin; this.Bootstrapper.PlanComplete += this.OnPlanComplete; } #region Properties private bool installAEnabled; public bool InstallAEnabled { get { return installAEnabled; } set { installAEnabled = value; RaisePropertyChanged(InstallAEnabled); } } private bool installBEnabled; public bool InstallBEnabled { get { return installBEnabled; } set { installBEnabled = value; RaisePropertyChanged(InstallBEnabled); } } 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); } } public BootstrapperApplication Bootstrapper { get; private set; } #endregion //Properties #region Methods private void InstallAExecute() { IsThinking = true; Bootstrapper.Engine.StringVariables[AToInstall] = A; Bootstrapper.Engine.Plan(LaunchAction.Install); } private void InstallBExecute() { IsThinking = true; Bootstrapper.Engine.StringVariables[BToInstall] = B; Bootstrapper.Engine.Plan(LaunchAction.Install); } private void UninstallExecute() { IsThinking =
Re: [WiX-users] Passing Variables from C# custom BA to WIX
I don't see anything obvious. Debugger is probably required. -Original Message- From: linos [mailto:lino...@hotmail.com] Sent: Thursday, July 31, 2014 20:09 To: wix-users@lists.sourceforge.net Subject: Re: [WiX-users] Passing Variables from C# custom BA to WIX Hi Rob, Thank You for the insight on using PlanPackageBegin event. I tried your recommendation in my wpf app, but haven't had much success. I have a simple wix ba project that contains one bundle and chain element. In my PlanPackageBegin event I have added source code to check for Netfx4Full. The problem here is that my PlanPackageBegin operation is never called. Although it has been subscribed to an event in my constructor. Where did I go wrong here in my implementation. I've added code for reference below: Wix Code: ?xml version=1.0 encoding=UTF-8? Wix xmlns=http://schemas.microsoft.com/wix/2006/wi; xmlns:util=http://schemas.microsoft.com/wix/UtilExtension; xmlns:bal=http://schemas.microsoft.com/wix/BalExtension; Bundle Name=My Test Application Version=1.0.0.0 Manufacturer=lino UpgradeCode=C82A383C-751A-43B8-90BF-A250F7BC2863 Variable Name =AToInstall bal:Overridable=yes Value=A Type=string/ BootstrapperApplicationRef Id=ManagedBootstrapperApplicationHost Payload SourceFile=..\TestBA\BootstrapperCore.config/ Payload SourceFile=..\TestBA\bin\Debug\TestBA.dll/ Payload SourceFile=..\TestBA\bin\Debug\GalaSoft.MvvmLight.WPF4.dll/ Payload SourceFile=C:\Program Files (x86)\WiX Toolset v3.8\SDK\Microsoft.Deployment.WindowsInstaller.dll/ /BootstrapperApplicationRef Chain PackageGroupRef Id='Netfx4Full' / MsiPackage Id=DummyInstallationPackageId SourceFile=..\DummyInstaller\bin\Release\DummyInstaller.msi Cache=yes Visible=no/ /Chain /Bundle Fragment WixVariable Id=WixMbaPrereqPackageId Value=Netfx4Full / WixVariable Id=WixMbaPrereqLicenseUrl Value=NetfxLicense.rtf / util:RegistrySearch Root=HKLM Key=SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full Value=Version Variable=Netfx4FullVersion / util:RegistrySearch Root=HKLM Key=SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full Value=Version Variable=Netfx4x64FullVersion Win64=yes / PackageGroup Id=Netfx4Full ExePackage Id=Netfx4Full Cache=no Compressed=yes PerMachine=yes Permanent=yes Vital=yes SourceFile=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40\dotNetFx40_Full_x86_x64.exe DownloadUrl=http://go.microsoft.com/fwlink/?LinkId=164193; DetectCondition=Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion) / /PackageGroup /Fragment /Wix C# wpf MainViewModel code: using Microsoft.Tools.WindowsInstallerXml.Bootstrapper; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using System; namespace Examples.Bootstrapper { public class MainViewModel : ViewModelBase { //constructor public MainViewModel(BootstrapperApplication bootstrapper) { System.Threading.Thread.Sleep(1); this.IsThinking = false; this.Bootstrapper = bootstrapper; this.Bootstrapper.ApplyComplete += this.OnApplyComplete; this.Bootstrapper.DetectPackageComplete += this.OnDetectPackageComplete; this.Bootstrapper.PlanPackageBegin += this.PlanPackageBegin; this.Bootstrapper.PlanComplete += this.OnPlanComplete; } #region Properties private bool installAEnabled; public bool InstallAEnabled { get { return installAEnabled; } set { installAEnabled = value; RaisePropertyChanged(InstallAEnabled); } } private bool installBEnabled; public bool InstallBEnabled { get { return installBEnabled; } set { installBEnabled = value; RaisePropertyChanged(InstallBEnabled); } } 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); } } public BootstrapperApplication Bootstrapper { get; private set; } #endregion //Properties #region Methods private void InstallAExecute() { IsThinking = true; Bootstrapper.Engine.StringVariables[AToInstall] = A; Bootstrapper.Engine.Plan(LaunchAction.Install
[WiX-users] Passing Variables from C# custom BA to WIX
I'm currently learning how to implement custom BA's through WIX and happen to run into a road block. I've created a custom GUI through WPF and need pass back to the WIX bootstrapper app, variables that I set in the C# application. Here is my C# function that calls the Bootstrapper app private void InstallAExecute() { IsThinking = true; Bootstrapper.Engine.StringVariables[AToInstall] = A; Bootstrapper.Engine.Plan(LaunchAction.Install); } and in my Boostrapper app, I have the following element Variable Name =AToInstall bal:Overridable=yes Value=A Type=string/ declared above my BootstrapperApplicationRef element. Then in my element Chain, I would like to add a conditional to trigger a particular msi to be installed when the variable satisfies the condition. This is what I have in my chain, but I think my syntax is incorrect. Chain PackageGroupRef Id='Netfx4Full' / MsiPackage SourceFile=..\Path\To\Installer.msi Id=InstallationPackageId Cache=yes Visible=no InstallCondition =AToInstall=A/ /Chain Any idea where I went wrong? -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113.html Sent from the wix-users mailing list archive at Nabble.com. -- Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071iu=/4140/ostg.clktrk ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users
Re: [WiX-users] Passing Variables from C# custom BA to WIX
Don't use variables. Process the PlanPackageBegin event and tell the engine the state of the package. -Original Message- From: linos [mailto:lino...@hotmail.com] Sent: Wednesday, July 30, 2014 13:24 To: wix-users@lists.sourceforge.net Subject: [WiX-users] Passing Variables from C# custom BA to WIX I'm currently learning how to implement custom BA's through WIX and happen to run into a road block. I've created a custom GUI through WPF and need pass back to the WIX bootstrapper app, variables that I set in the C# application. Here is my C# function that calls the Bootstrapper app private void InstallAExecute() { IsThinking = true; Bootstrapper.Engine.StringVariables[AToInstall] = A; Bootstrapper.Engine.Plan(LaunchAction.Install); } and in my Boostrapper app, I have the following element Variable Name =AToInstall bal:Overridable=yes Value=A Type=string/ declared above my BootstrapperApplicationRef element. Then in my element Chain, I would like to add a conditional to trigger a particular msi to be installed when the variable satisfies the condition. This is what I have in my chain, but I think my syntax is incorrect. Chain PackageGroupRef Id='Netfx4Full' / MsiPackage SourceFile=..\Path\To\Installer.msi Id=InstallationPackageId Cache=yes Visible=no InstallCondition =AToInstall=A/ /Chain Any idea where I went wrong? -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113.html Sent from the wix-users mailing list archive at Nabble.com. -- Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071iu=/4140/ostg.clktrk ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users -- Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071iu=/4140/ostg.clktrk ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users
Re: [WiX-users] Passing Variables from C# custom BA to WIX
since the variable is defined as a string, you need to add quotes around the value that you are comparing the string too. I prefer to use html entities, but you might prefer a different approach. InstallCondition =AToInstall=quot;Aquot If the variable were defined as a numeric, then the syntax is as you used with the value a number. -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113p7596115.html Sent from the wix-users mailing list archive at Nabble.com. -- Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071iu=/4140/ostg.clktrk ___ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users