oleg-shilo / wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
MIT License
1.12k stars 175 forks source link

Add Custom WPF Dialog to Setup #1517

Closed Torchok19081986 closed 6 months ago

Torchok19081986 commented 6 months ago

morning, i combat since last week with Example External_UI / WpfSetup. I did some changes for startwindow , mainwindow, not to install immediatly , proceed to antoher window. Sofar ok, but how do i pass Installdir to Embeded MSI ? I know that i have to set it into Session, but it didnt work. I think , i missed something.


session["MYINSTALLDIR"]  = InstallDirWindow.Text;

i also set in msi extra properties for it.


project.DefaultDefferedProperties = ",MYINSTALLDIR";
oleg-shilo commented 6 months ago

You need to pass the installdir value as an input property value when you run your msiexec.

It looks like you opted to give your installdir that id , which has value MYINSTALLDIR. So you do it via MSIEXEC this way:

msiexec /i my.msi MYINSTALLDIR="c:\anydir\anysubdir" 

image

Torchok19081986 commented 6 months ago

thanks for exmplanation, @oleg-shilo. I think , now i got this. I need to create UserInput public Property and add it to msi package, just like in example of yours.

MsiProperties = "USERINPUT=[UserInput]

then i can set it. That was my mistake, i thought , i need do it before. Am i on right way, if i guess, msi doesnt show ui from it self and it will be reflected on my wpf ui ? If "CUSTOM_UI=true" is set or i need to do something ?

i tested it out. cmd-line


msiexec /i MyProduct.msi CUSTOM_UI="true" ADDLOCAL=Binaries,Documentation INSTALLDIR="C:\Apps\"

works fine. Only one difficulty : how to suppress msi ui ? I could set it to ManagedUI for standard Dialogs WPF like


project.ManagedUI = ManagedUI.DefaultWPF;

returns 1602 or 1603 msi error.

only project.UI = WUI.WixUI_Common works well.

Torchok19081986 commented 6 months ago

my mistake. 1602 and 1603 msi error , because i got typo error in string after CUSTOM_UI= "true". Now i need to bring it to MVVM Pattern in WPF. how do i get rid of caliburn.macro and use another MVVM Framework. I would like to use CommunityToolKit.MVVM , but Generic Setup class rely on Caliburn.Macro. Also Commands are better to use in CommunityToolkit.MVVM.

oleg-shilo commented 6 months ago

Also Commands are better to use in

LOL, that's exactly where Caliburn shines. The only WPF command setup in CM is "if you named your button 'Exit' then the command that will be automatically attached to it is the ViewModel method that is called 'Exit'". Nothing can be better/simpler than that.

Af you do not want to use Caliburn then you don't. Just do not call any of its methods. The dialogs themselves are just ordinary WPF UserControls. But still, start your UI definition from the VS template with the all dialogs defined and then replace Caliburn binding with your alternative. As below

image

Torchok19081986 commented 6 months ago

maybe, but i use since last year communitytoolkit.mvvm for anything as MVVM Framework. there are some reasons for this. Internal move to MVVM. For example https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/generators/relaycommand