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

How to debug the installer script using csscript.exe ? #1537

Closed Aaswin1996 closed 6 months ago

Aaswin1996 commented 6 months ago

I am creating a ManagedUI Project with multiple dialogs as soon as i click on the next button of the welcome dialog installer vanishes nothing happens .

setu.cs code :

`static void Main() { Compiler.PreserveTempFiles = true; var project = new ManagedProject("MyProduct", new Dir(@"%ProgramFiles%\My Company\My Product", new File("Program.cs")));

project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b");
project.ValidateBackgroundImage = false;

//custom set of standard UI dialogs
project.ManagedUI = new ManagedUI();

project.ManagedUI.InstallDialogs.Add<WelcomeDialog>()
                                .Add<LicenceDialog>()
                                .Add<SetupTypeDialog>()
                                .Add<FeaturesDialog>()
                                .Add<InstallDirDialog>()
                                .Add<ProgressDialog>()
                                .Add<ExitDialog>();

project.ManagedUI.ModifyDialogs.Add<MaintenanceTypeDialog>()
                               .Add<FeaturesDialog>()
                               .Add<ProgressDialog>()
                               .Add<ExitDialog>();

//project.SourceBaseDir = "<input dir path>";
//project.OutDir = "<output dir path>";

ValidateAssemblyCompatibility();

project.BuildMsi();

}`

Dialog.cs code `public partial class WelcomeDialog : ManagedForm, IManagedDialog // change ManagedForm->Form if you want to show it in designer { ///

/// Initializes a new instance of the class. /// public WelcomeDialog() { InitializeComponent(); }

void WelcomeDialog_Load(object sender, EventArgs e)
{
    MessageBox.Show(Runtime.Session.ToString());
    image.Image = Runtime.Session.GetResourceBitmap("WixSharpUI_Bmp_Dialog");
    ResetLayout();
}

void ResetLayout()
{
    // The form controls are properly anchored and will be correctly resized on parent form
    // resizing. However the initial sizing by WinForm runtime doesn't do good job with DPI
    // other than 96. Thus manual resizing is the only reliable option apart from going WPF.

    MessageBox.Show("Resetting layput");
    var bHeight = (int)(next.Height * 2.3);
    MessageBox.Show("Resetting 1");
    var upShift = bHeight - bottomPanel.Height;
    MessageBox.Show("Resetting 2");
    bottomPanel.Top -= upShift;
    MessageBox.Show("Resetting 3");
    bottomPanel.Height = bHeight;
    MessageBox.Show("Resetting 4");

    imgPanel.Height = this.ClientRectangle.Height - bottomPanel.Height;
    MessageBox.Show("Resetting 5");

    /*float ratio = (float)image.Image.Width / (float)image.Image.Height;
    MessageBox.Show("Resetting 6");
    image.Width = (int)(image.Height * ratio);
    MessageBox.Show("Resetting 7");
    textPanel.Left = image.Right + 5;
    MessageBox.Show("Resetting 8");
    textPanel.Width = (bottomPanel.Width - image.Width) - 10;*/
    MessageBox.Show("Resetting layput finisheds");
}

void cancel_Click(object sender, EventArgs e)
{
    Shell.Cancel();
}

void next_Click(object sender, EventArgs e)
{
    MessageBox.Show("Going to Next");
    MessageBox.Show(e.ToXValue().ToString());
    Shell.GoNext();
}

void back_Click(object sender, EventArgs e)
{
    Shell.GoPrev();
}

}`

Torchok19081986 commented 6 months ago

Hiho, you use WPF template, right ? you dialog, according to this code, doesnt implement IWpfDialog Interface and many another Interfaces. I think, msi doesnt know here aboud your session, and disapears. new Dialog should implement Interface and ineherit from WpfDialog.


public partial class WelcomeDialog : WpfDialog, IWpfDialog
oleg-shilo commented 6 months ago

Here is the debugging instructions: https://github.com/oleg-shilo/wixsharp/wiki/Tips'n'Tricks#debugging

And I advise you to create your project from the VS WixSharp templates so you know for sure that your dialogs source code complies with the msi hosting interface expectations.

Aaswin1996 commented 6 months ago

Hiho, you use WPF template, right ? you dialog, according to this code, doesnt implement IWpfDialog Interface and many another Interfaces. I think, msi doesnt know here aboud your session, and disapears. new Dialog should implement Interface and ineherit from WpfDialog.

public partial class WelcomeDialog : WpfDialog, IWpfDialog

No I don't use WPF templates .Have created my project from VS WixSharp Template