How to add additional custom window to VS setup projects UI flow - c#

I'm using a VS 2008 setup project to deploy my application to client computer.
Now I need to add custom UI Window to get some information form user for set up process.
As example, there should be a form to enter user information after click next button of the destination folder search window.
How can I do this?

If you want to get user input using custom UI during the MSI deployment best approach is to create the .wid extension files. this is the type of UI files that you see during the MSI installation(where you select the installation path etc). Even though visual studio doesn't have features to create these UI files there are Microsoft tools you can use to create these files. One of the best tool is Orca.
Orac.exe
How to use the Orca database editor to edit Windows Installer
files
Once you create the UI file, you have to place the file under C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\Deployment\VsdDialogs\1033 (it's where MSI picks the default UI files from)
After that you should be able to select your custom UI and inject it during any phase of installation cycle(beforeinstall, install, afterinstall etc). Then you can pass the value user has entered into the text field as a argument for installer class. Then you can read the value within the installer class using context parameter.
string value = Context.Parameters["ParameterName"];

Related

How to customize the Setup wizard with custom forms in Visual Studio setup project

I have to create a setup project with custom serial key validation. I have to proceed the installation only after the serial key is authenticated or else we have to skip the installation.
I have tried the sample setup project, and have called the custom form for authenticating serial key in the installer class, merged the installer class from the custom action in the setup project.
But the Serial key validation form comes after the progress form executes.
I need to show it after the welcome page.
I have attached the screenshot of the setup wizard.
How to bring the Setp 5 form (custom form) before Step 2?
This can't be done in Visual Studio setups - the only validation supplied is the serial number template, a masked edit control to verify the basics. This is because Visual Studio setups custom actions all run after the files are installed, and you cannot associate one with a button click to validate the serial number, or in fact anything in the UI.
You might need to use another tool for your setup. VS setups are pretty simple but they don't have many features. Otherwise you could use another tool to build a merge module that you could add. Manually editing the MSI file is a possibility but you'd need to know a lot about the internals of MSI files.

C# custom action windows form focused issue

Background:
I used Visual Studio setup project to deploy one of C# application to client windows server.
While installing the application I need to setup a scheduled task in the server as well
For this I used a Custom Action feature in the setup project. What I did is created a windows form with input fields and "ok" button and once user enter values and click on the "ok" button task will be created. I added this custom task in Install and Commit steps in Custom Action.
Issue
: Everything works fine but when the created windows from shows, it lost the focuses even I used showDialog method to show the form. So always main setup window will active and users not see the popup form in background (see the attached image).But I can click on the popup window and make it activate. I tried with SetActiveWindow method also but no good result so far.
Simple what I need is to activate the popup window untill user action (default showDialog behavior). So here I'm looking for any help.
If you want to get user input using custom UI during the MSI deployment best approach is to create the .wid extension files. this is the type of UI files that you see during the MSI installation(where you select the installation path etc). Enough though visual studio doesn't have features to create these UI files there are Microsoft tools you can use to create these files. One of the best tool is Orac.
Orac.exe
How to use the Orca database editor to edit Windows Installer files
Once you create the UI file, you have to place the file under C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\Deployment\VsdDialogs\1033 (it's where MSI picks the default UI files from)
After that you should be able to select your custom UI and inject it during any phase of installation cycle(beforeinstall, install, afterinstall etc). Then you can pass the value user has entered into the text field as a argument for installer class. Then you can read the value within the installer class using context parameter.
string value = Context.Parameters["ParameterName"];

C# Install - Change a custom folder location using install dialog

I am trying to install a windows service using a visual studio setup project. All is going well except I want the user to be able to use the install dialog to specify the location of a custom folder to be created during installation.
I've added a Textboxes dialog that stores a folder location in an Install Property (PATHPROPERTY in this example) but I can't figure out how to use that to change the path of a folder I'm creating during the installation. I set the 'Default Location' Property of the custom folder in the 'File System' menu to:
"[PATHPROPERTY]\folder"
But when I change the path in the install dialog, the folder is created at the default location of PATHPROPERTY, not what I change it to during install. So it seems like the folder is created before I reach the point in my dialog where I ask for the path.
I noticed that there is a Property Property for the folder that I can set and supposedly use to modify the location of the folder during installation, and I've seen some articles suggesting that this can be used to set the location using a command line flag. But I would like to be able to use the install dialog, then possibly set this property in my installer class, but I haven't found any documentation on how to do that yet..
I also found something about Session.Property to set the property but the documentation wasn't clear on how to use this.
Any help would be much appreciated.
Oh. Also. I'm targeting .NET 3.5.
So PATHPROPERTY returns the custom folder location user has selected, If thats the case you have to set that property to "Property" attribute.
Also make sure in the User Interface Editor you are getting the user input before installation starts. (You can move up and down the UI to required position)

Autoinstallaion of setup.exe

I am using visual studio 2008 and I have created setup project using the same. After deployment of the application whenever I change any of the file or even rename any file setup.exe automatically starts to reinstall the setup. In this case it should customized error.
Do anybody has idea on this??
This is the normal behavior. Windows Installer automatically performs a repair if it determines that some of the installed resources are missing.
This repair is triggered by:
launching the application through an advertised shortcut
launching a file associated with your application
To avoid it you should:
make sure that your application doesn't delete, move or rename installed files; if you need to work with files use the Application Data folder
or
make sure that the deleted file is not the key member in its component; this is controlled through the Component table
To answer your actual question, you cannot show a customized error. You can only try to avoid this behavior.

How to execute custom action before installing files when using VS's Setup Project?

I have a simple VS setup project. On the first screen user inputs database name and credentials to access it. Then user clicks 'Next' button and files are copied.
I would like to add one check which should be executed after user typed database name and credentials, but before copying files. This check should hit the database and verify some info. And depending on the result of this check installation will be continued or interrupted.
How could i do it? Is it possible to do it using VS setup project?
Thanks
I've figured out that it is impossible to execute custom action before installing files using VS's setup project. This is because VS's setup project copies files at first and after that executes custom actions. This is by design.
That's why I decided to create a small winforms application with setup's interface and required behavior.

Categories