To validate user install step in installer project in Visual Studio 2022

43 views Asked by At

I have a Winforms application and for this I created a setup project in the same solution. I want to a create a dialog (custom action) for validating a user. If user auth is successful, the installation can continue. Do you have an idea how to do this?

[RunInstaller(true)]
public partial class AppInstaller : System.Configuration.Install.Installer
{
     public AppInstaller()
     {
         InitializeComponent();
     }

     public AppInstaller(IContainer container)
     {
         container.Add(this);
         InitializeComponent();
     }

     public override void Install(IDictionary stateSaver)
     {
         base.Install(stateSaver);

         string username = Context.Parameters["Username"];
         string password = Context.Parameters["Password"];

         bool check = CheckSetupUser.ValidateUser(username, password);

         if (!check)
         {
             throw new InstallException("The Installation doesn't continue");
         }
     }
}

I tried several method like CustomInstaller class but I didn't succeed.

0

There are 0 answers