Walkthrough: Deploying Your Program (C++)
Now that you've created your application by completing the earlier related walkthroughs, which are listed in Using the Visual Studio IDE for C++ Desktop Development, the last step is to create an installer so that other users can install the program on their computers. To do this, you'll add a new project to your existing solution. The output of this new project is a setup.exe file that will install your app on another computer.
This walkthrough shows how to use Windows Installer to deploy your application. You can also use ClickOnce to deploy an application. For more information, see ClickOnce Deployment for Visual C++ Applications. For more information about deployment in general, see Deploying Applications, Services, and Components.
This walkthrough assumes that you understand the fundamentals of the C++ language.
It also assumes that you have completed the earlier related walkthroughs that are listed in Using the Visual Studio IDE for C++ Desktop Development.
This walkthrough cannot be completed in Express editions of Visual Studio.
If you haven’t already done so, download the Microsoft Visual Studio Installer Projects extension, as described in the steps later in this article. The extension is free for Visual Studio developers and adds the functionality of the setup and deployment project templates to Visual Studio.
To install the Visual Studio setup and deployment project template
When you are connected to the Internet, in Visual Studio, choose Tools > Extensions and Updates.
Under Extensions and Updates, select the Online tab and type Microsoft Visual Studio Installer Projects in the search box. Hit Enter, select Microsoft Visual Studio 2017 Installer Projects, and click Download.
Choose to install the extension, then restart Visual Studio.
On the menu bar, choose File > Recent Projects and Solutions, and then choose the Game solution to reopen it.
To create a setup project and install your program
Change the active solution configuration to Release. On the menu bar, choose Build > Configuration Manager. In the Configuration Manager dialog box, on the Active solution configuration drop-down list, select Release. Choose the Close button to save the configuration.
On the menu bar, choose File > New > Project to open the New Project dialog box.
In the left pane of the dialog box, expand the Installed > Other Project Types nodes, and then select Visual Studio Installer. In the center pane, select Setup Project.
Enter a name for the setup project in the Name box. For this example, enter Game Installer. In the Solution drop-down list, select Add to solution. Choose the OK button to create the setup project. A File Assistant (Game Installer) tab opens in the editor window.
Right-click the Application Folder node and select Add > Project Output to open the Add Project Output Group dialog box.
In the dialog box, select Primary Output and click OK. A new item named Primary Output from Game (Active) appears.
Select the item Primary Output from Game (Active), right-click and choose Create Shortcut to Primary Output from Game (Active). A new item named Shortcut to Primary Output from Game (Active) appears.
Rename the shortcut item to Game, then drag and drop the item into the User's Programs Menu node on the left side of the window.
In Solution Explorer select the Game Installer project and choose View > Properties Window or hit F4 to open the Properties window.
Specify additional details as you want them to appear in the installer. For example, use Contoso for Manufacturer, Game Installer for Product Name, and http://www.contoso.com for SupportUrl.
On the menu bar, choose Build > Configuration Manager. In the Project table, under the Build column, check the box for Game Installer. Click Close.
On the menu bar, choose Build > Build Solution to build the Game project and the Game Installer project.
In the solution folder, locate the setup.exe program that was built from the Game Installer project, and then run it to install the Game application on your computer. You can copy this file (and GameInstaller.msi) to install the application and its required library files on another computer.
Previous: Walkthrough: Debugging a Project (C++)