Creating installer packages
The release of Visual Studio 2012 marked the removal of the popular Visual Studio Installer project type. Just like 2012, Visual Studio 2013 offers a version of the third-party InstallShield. In this case: InstallShield Limited Edition.
The need for an installer depends on the type of application you are working on. If you are creating a Windows Store app, then you don't need an installer, as the new deployment model makes installers obsolete. If you are creating a web application, then Microsoft would suggest you to either use the XCopy or the MSDeploy web deployment technology. When it comes to traditional desktop applications, you may want to use InstallShield. You can always fall back to using the WiX (Windows Installer XML) toolset (http://wixtoolset.org/) for creating projects.
In this recipe, we will use InstallShield to create an installer package for a simple application.
Getting ready
The recipe assumes you haven't yet installed InstallShield Limited Edition. If you have, then some of the early steps in this recipe will be different.
Simply start Visual Studio 2013 (Professional or higher), and you're ready to go.
How to do it…
Create an installer using the following steps:
Create a new Visual C# | WPF Application project and name it
Simple WPF Application
.Go to the project properties page by right-clicking on the project in Solution Explorer and selecting Properties. In the Application tab, set the icon for the application to either an icon of your choice or the icon located at
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\General\1033\Icon\Icon.ico
.Build the solution to make sure it compiles properly. If you have already installed InstallShield Limited Edition, you can jump down to step 7.
Right-click on the solution and add a new project using the Other Project Types | Setup and Deployment | Enable InstallShield Limited Edition template.
A browser window will appear with instructions on how to enable InstallShield in Visual Studio 2013. Click on the link to redirect to the InstallShield website, register your details, and download the file as directed. When the download completes, save your solution, close Visual Studio 2013, and then run the InstallShield setup executable.
Restart Visual Studio 2013 and open the solution you created in Step 1.
Right-click on the solution in Solution Explorer and choose Add | New Project... from the context menu. In the Add New Project dialog, choose Other Project Types | Setup and Deployment | InstallShield Limited Edition Project, give it the default name, and then click on OK.
If this is the first time you have used InstallShield after installation, you will be asked whether you wish to evaluate the software or register it. Choose to register and activate the product using the serial number you should have received in your e-mail.
The InstallShield project assistant will appear in the document window, as shown in the following screenshot:
Click on the right arrow (the "next" button) at the bottom of the project assistant window to advance to the Application Information page. Enter a company web address, such as
www.company.com
.Advance through the project assistant until you get to the Application Files page. Select the My Product Name node from the tree and then click on Add Project Outputs, as shown in the following screenshot:
In the Visual Studio Output Selector dialog, select the Primary output item and click on OK.
Click on the next button to go to the Application Shortcuts page. Click on the New... button to add a shortcut to your application. Choose [Program FilesFolder] | My Company Name | My Product Name | Simple WPF Application.Primary output from the dialog and click on Open.
The shortcut is named Built by default. That's not very useful, so click on the shortcut name to edit it and rename it to
Simple WPF Application
.Right-click on the Setup1 project in Solution Explorer and select Install from the menu. If prompted to build out-of-date projects, click on Yes.
Follow the steps through the setup wizard to install the program. Verify that the program is installed correctly by looking for the application in your Start menu or Start page, as shown in the following screenshot:
Remove the program from your system by right-clicking on the Setup1 project (from within Visual Studio) and selecting Uninstall.
How it works...
InstallShield reduces the complexity of creating installers by providing a set of sensible default configuration options and an easy-to-use user interface. It also understands exactly how the Windows installer system works and warns when there are problems in how you have configured the installation process. For example, if you recall the warning outputs from the Creating installer packages recipe when the package was built, you would have seen a warning about the .NET Framework and how it would be a good idea if this framework was included with the setup kit to ensure people who don't have .NET already installed won't have extra setup dependencies.
A license for the limited edition is provided free of charge with Visual Studio 2013 and will be sufficient for basic installation purposes. If you need a heavily-customized installation process, then you should investigate the more advanced versions of InstallShield, or competing offerings such as Nullsoft Scriptable Install System (NSIS), or the previously mentioned WiX.
See also
Microsoft has developed ClickOnce, which can also be used to deploy Windows-based applications. More information is available at http://msdn.microsoft.com/en-us/library/t71a733d.aspx.
Developers writing applications in C++ should also review the ClickOnce information at http://msdn.microsoft.com/en-us/library/ms235287.aspx.
Nullsoft Scriptable Install System (NSIS): http://nsis.sourceforge.net/Main_Page.