oleg-shilo / wixsharp

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

Event not working #1235

Closed serezlan closed 1 year ago

serezlan commented 1 year ago

Hi,

I'm trying to get something done at the beginning of installer. From the sample, this should be achievable through UILoaded event. However I cannot get my code executing.

Could you help me pinpoint the problem? Here's the code:

var project = new ManagedProject(GetProductNameWithVersionNumber(), new Dir(string.Format("%ProgramFiles%\{0}\{1}", cfg[Util.Config.CompanyNameKey], cfg[Util.Config.ProductNameKey]), new Files(cfg[Config.BaseDirKey] + ".")));

        project.UILoaded += Init3;

// ...

public static void Init3(SetupEventArgs e) { var tmpFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "delta.txt"); System.IO.File.WriteAllText(tmpFile, "alpha centauri"); }

There should be a file in temp dir.

Thx.

oleg-shilo commented 1 year ago

UILoaded is only firing when user defines managed UI as the UI for your setup. If it is the native UI you are using, then it will not fire. Quite possibly it is your case.

Load (or BeforeInstall) fires before the install starts and it has no connection to what UI you are using.

Read more here: https://github.com/oleg-shilo/wixsharp/wiki/Managed-Setup-Model#event-driven-custom-actions

serezlan commented 1 year ago

Sorry for my late response. I've redo my work based on your information and git it working.

Thx.