Jun 24, 2011

The Visual Studio MSI Installer

The Click Once installer in Visual Studio is very discoverable and I've known about it and used it for years. I don't like it but I've used it, especially when a project has multiple dependencies. Much less discoverable is the fact that a more standard MSI installer is also included in Visual Studio. Why am I always the last to find out?  Here are some step by step instructions for creating an MSI installer from inside Visual Studio 2010. (If you’ve upgraded to VS2012 see InstallShield Limited Edition and VS2012.

Step 1.

SNAGHTML6ee87d8Right-click on your solution and choose Add-> New Project…


Step 2.

SNAGHTML6f264eeOpen up the Other Project Types->Setup and Deployment->Visual Studio Installer (OK it wasn't that hard to discover but I seldom get past the Visual C# option. ) Enter a name and hit OK.

Step 3.

SNAGHTML6f5c555Walk through the wizard. In my case when selecting files I only needed to select the Content Files and Primary Output. I have an xml file that resides in a XmlData folder that must get created but since I marked its build property as content the wizard will take care of that automatically.


Step 4.

imageWhen the wizard is done you should have a new project and a new pane called File System should be open. If it's not you can right-click on your new project and select the View menu and select the File System option. You'll notice there are several other interesting options that deserve further exploration in the future.

Step 5.

SNAGHTML7931607If you want shortcuts to your application put in the Start menu and on the desktop, you have a couple of steps left. Also, I want my shortcuts to have the proper icons, so I'll include the steps for that. In the File System pane click on the Application folder and then in the right pane right click on the Primary output as shown and select the option for creating a shortcut as shown.

Step 6.

imageClick on the created shortcut and give it a  better name. Then in the properties pane locate the Icon option and from the drop down select (Browse…) as shown at left.

Then in the dialog click the Browse… button (see the figure below). In the Select Item in Project dialog select the Application Folder at the top, select Executable Files (*.exe) from the Files of Type drop down and click on your primary output (as shown below) to pick the icon you associated with your application. This will result in the second dialog shown below where a small version of your icon is shown. Don't worry the appropriate size will be shown for the shortcut. Click OK and then drag the shortcut file into the User's Desktop folder. You can repeat this process again and drag the second copy into the User's Programs folder. In the User's Programs menu if you want to group your choices under your company name you can add a folder like I did in the above dialog for ITS-9202 and drag the shortcut into that folder. As you can tell I dragged the shortcut there before I set the icon. The order you perform these steps is not important.




Step 7 (The Final Step)

imageIn the Solution Explorer right-click on your new install project and select Build. When the build finishes you can right-click again and select Open Folder in Windows Explorer and go try out your new installer. There are separate folders for your Release and Debug configurations so be sure to build both. Each folder should contain a setup.exe and the associated .msi file. I only ever use the Release version for the copy sent to the final client.

More Optional Steps

imageYou can click on the installer project and then check out the properties panel to see many other options that can be set. There are also option panels for each of the folders in your project. Examples of both property panes are shown to the left and  below. I've marked a few of the items in the project properties that I usually change. Your choices for customization aren't limited to what I've shown here, but this is as far as my experience has taken me.


Related Posts

Visual Studio Installer Part 2
InstallShield Limited Edition and VS2012
When the VS Setup doesn’t get the .NET client right  ...

About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.