It's hard for me to comment on your code as the only thing that I know about it is that "it doesn't work".
The following is a complete code that does work. You probably will be able to adjust it to your requirements:
The following is a complete code that does work. You probably will be able to adjust it to your requirements:
//css_dir ..\..\..\;//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;//css_ref WixSharp.UI.dll;//css_ref System.Core.dll;//css_ref System.Xml.dll;using System; using System.Collections.Generic; using System.Diagnostics; using System.Windows.Forms; using WixSharp; using WixSharp.Forms; using WixSharp.UI.Forms; publicclass Script { staticpublicvoid Main() { var project = new ManagedProject("ManagedSetup", new Dir(@"%ProgramFiles%\My Company\My Product", new File(@"..\Files\bin\MyApp.exe"), new Dir("Docs", new File("readme.txt")))); project.ManagedUI = ManagedUI.Empty; project.Load += project_Load; project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); Compiler.BuildMsi(project); } staticvoid project_Load(SetupEventArgs e) { try { if (string.IsNullOrEmpty(e.Session["INSTALLDIR"])) //installdir is not set yet { string installDirProperty = e.Session.Property("WixSharp_UI_INSTALLDIR"); string defaultinstallDir = e.Session.GetDirectoryPath(installDirProperty); e.Session["INSTALLDIR"]= System.IO.Path.Combine(defaultinstallDir, Environment.UserName); } } catch { } MessageBox.Show(e.ToString(), "Load"); } }