PDA

View Full Version : How to execute application C# code during the installation of this application?



vgeniy
02-02-2017, 01:45 AM
Hello. First, I bag your pardon for my poor English. I create Windows installation project (ISM) of my C# WPF Prism MVVM modular application. In my C# WPF application I have Properties.Settings.Default flag called IsFirstRunAfterInstallation. The type of this flag is bool. I need that this flag must be set to true during the installation process. After completion of the installation when the application is run first time, IsFirstRunAfterInstallation flag is checked as the following:

if (My_assembly_name.Properties.Settings.Default.IsFirstRunAfterInstallation)
{
// do some actions here that must be done when application runs first time after its installation.
. . . . . . . . . . . . . . .
My_assembly_name.Properties.Settings.Default.IsFirstRunAfterInstallation = false;
My_assembly_name.Properties.Settings.Default.Save();
}

And if IsFirstRunAfterInstallation flag is true, some C# code that is needed to perform when the application runs first time will be executed (as you can see above). I need that IsFirstRunAfterInstallation flag is set to true like the folowing:

My_assembly_name.Properties.Settings.Default.IsFirstRunAfterInstallation = true;
My_assembly_name.Properties.Settings.Default.Save();

during each installation of my application and is checked after the installation when the application runs first time. So I have the followin question: How to execute application code during the application installation using InstallShield 2016 Premier Edition (21-days trial)?

Thanks in advance. Eugene.

chad.petersen
02-02-2017, 12:13 PM
C# code is run thru what is called a Custom Action in installers. Are your settings being saved to a file in this case?

I use this technology to run all of my C# code through the MSI file these days. By authoring it using these tools it appears to MSIEXEC.EXE as a standard Win32 DLL, but the compiler takes care of the extra work in this case. So, I code in C# and using the DTF tools from WiX it spits out the Win32 compatible file.

http://blog.iswix.com/2008/05/deployment-tools-foundation-dtf-managed.html

It's one way to accomplish it.

Chad