Creating an install MSI file is rather simple; however there is very little documentation about it, or it's choppy and sometimes too wordy. Well, the point of this article is to show you how to create the installer application, and how to make it launch your application after it has finished installing.
Using the Code
The first thing you must do is add a new reference to your main project file.
System.Configuration.Install to your project, for some reason this has not been added automatically.
Now you must add an installer class to your main project. To do this, right click on that project, go to Add, and go to New Item…
Name it Installer Class.
Copy and paste the following code into your application. Be sure to change the application name to that of your main project, in my case it is InstallSample.exe.
Public Class InstallerClass
Public Sub New()
AddHandler Me.Committed, AddressOf MyInstaller_Committed
AddHandler Me.Committing, AddressOf MyInstaller_Committing
Private Sub MyInstaller_Committing_
(ByVal sender As Object, ByVal e As InstallEventArgs)
Private Sub MyInstaller_Committed(ByVal sender As Object, _
ByVal e As InstallEventArgs)
(Assembly.GetExecutingAssembly().Location) + "\InstallSample.exe")
Public Overloads Overrides Sub Install(ByVal savedState As IDictionary)
Public Overloads Overrides Sub Commit(ByVal savedState As IDictionary)
Public Overloads Overrides Sub Rollback(ByVal savedState As IDictionary)
public class InstallerClass : System.Configuration.Install.Installer
this.Committed += new InstallEventHandler(MyInstaller_Committed);
this.Committing += new InstallEventHandler(MyInstaller_Committing);
private void MyInstaller_Committing(object sender, InstallEventArgs e)
private void MyInstaller_Committed(object sender, InstallEventArgs e)
Assembly.GetExecutingAssembly().Location) + "\\InstallSample.exe");
public override void Install(IDictionary savedState)
public override void Commit(IDictionary savedState)
public override void Rollback(IDictionary savedState)
After changing the project EXE file in the source code that you just pasted, be sure to recompile that project.
As you can see from the code, you added a new interface to the class that allows you to take control of the Install, Commit, Committed, and Rollback. In Committed, I am going to launch the InstallSample.exe application.
When it is time to create your install project, you will want to add a new Setup Project to your existing applications solution.
Right click on this new project, then click Add, then go to Project Output…
Select Primary Output, then click OK.
Add a shortcut in the Start Menu… Right click on the Setup Project, then go to View, and then File System…
Click on Application Folder, then right click the Primary Output file, and then go to Create Shortcut to Primary Output from InstallExample (Active):
Add a new folder to your start menu, right click on User's Programs Menu, then go to Add, and then Folder. Rename that folder to Installer Example.
Now drag that shortcut you created in the Applications Folder, to the new folder you just created:
Right click on the new solution; go to View, then Custom Actions:
Add a new custom action to the root Custom Actions node:
Double click Applications Folder:
Then click Primary output from InstallExample (Active):
Lastly, rebuild your install solution.
It is a good idea to keep an eye on the status bar, it will tell you when it is done…
Now you can test it and it should install the application. After the install process, it should run automatically.
- 11th July, 2007: Initial post