Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Installing a production application on a local computer is more than just copying files to the Program Files folder. You might need to check for dependencies and verify that a previous licensed version is available before continuing. You may need to remove certain files before installing the new version. It is a common practice to create items in the Start menu and copy help and documentation files to the computer. If you need to perform any of these tasks, you must create a setup program. The Windows Installer API exists to assist us in these scenarios. Visual Studio contains an installer project that creates Windows Installer files for your application.
For this demonstration, I'm going to use a solution called InstallerDeploy that contains the application that I want to install, which is PixelSmithDesktop. This is that WPF application we've seen in other movies in this chapter. I'm going to start by adding an installer project. I'll right-click on my Solution and choose Add > New Project. Then I'll move down to the Other Project section and choose Setup and Deployment. There are two setup projects available here: InstallShield LE and Visual Studio Installer. This is a third-party application and it's an add-in to Visual Studio.
I'm going to choose the Visual Studio Installer, and then I'm going to choose the Setup Wizard. I'll give this a better name. I'll call this one PixelSmithInstaller and then click the OK button. Since this is a wizard, it'll start walking me through these questionnaires. Welcome. Thank you. What kind of application setup do you want? Is this for a Windows or web application? This is for a Windows application. I don't need any of the special packages, so I'll click on Next. Here I'm picking the files that are coming out of my application.
This indicates that I want all of the files necessary to run the application: the Primary output, EXE, and DLL. This would be the source code, like the C# files. Obviously, I don't need that from my end users. This is for my debugging symbols. I don't need that, but I do need content files and documentation files if I have those. So I'll click Next. Here I can add additional files. I'll click on the Add button, and then in this Other Files folder, you'll find a number of extra files. There is a Windows movie in here.
There is a help file, there is a PDF, and a document file, and an RTF. I'm going to select all of these and then click Open and then Next. At this point, I'm done. I'll click on the Finish button. As you can see, a new project was added to my application. Now let me show you what happens when you go to build your application. If I go up here and I choose Build Solution, that normally would build all of the projects that are inside my solution. But as you can see from my Output window, it only built my main application; it did not build the installer.
I think this is because you don't create installers until the end of your project cycle. Since installers can take a long time to build, the default mode is to not build this file when you choose to build the solution. Obviously, I do need to build it, so the way I can build the application is to right-click and choose Build. At this point, the installer is ready to run. I can right-click here and choose Install. And later when the application is installed, I can choose Uninstall from this location. I'll start the install process by clicking here. It's got the wrong name up here, PixelSmithsInstaller.
It should say PixelSmithDesktop. So I need to fix that. So let me cancel out of here. Choose Yes and then choose Close. I need to change a couple of settings. To configure my application, there is two places I can go. One is I can click on the project and edit items in the Property window. For instance, I don't want this to say Microsoft as the manufacturer; I want it to say Lynda. Also, the ProductName is wrong. It should say PixelSmithDesktop version 2, and I'll also change the Author to Lynda like that.
Another place I can change the configuration is by right-clicking and choosing View. The only one that I want to change for this demo is User Interface. So let me click here. These are the different screens that are going to show up during the installation process. What I would like to do is add a custom Readme to this install. So what I will do is right-click on Start and choose Add Dialog. Then I'll come over here and choose Read Me. OK. Next, I'm going to drag this Read Me up to the top of the list, so that it's second from the Welcome screen. So they'll see the Welcome screen. Then they'll see my Read Me.
I also need to tell what text to show. So I'll come over here and click the ReadmeFile. Browse for that. I'll look in my Application Folder, find this ReadMe.rtf file and click OK. I'm done with the changes to the user interface. Next, I'm going to change what's installed on the user's computer. Here is the Application Folder. I would like to add some extra folders to this location. So I'm going to right-click and choose Add > Folder, Samples and Add > Folder, Documents.
Now I can go back to my Application folder and drag the files to the location where I want them to be installed on the user's computer. So this documentation file and this movie file I think those belong in the Documents folder, so I'll drag those over here. And these two sample files, I'll drag those over to the Samples folder. Now I'll add a shortcut to the user's desktop. That's accomplished by coming over here and right-clicking, choosing Create New Shortcut. I want to create a shortcut to the Primary output, which will be my EXE.
I should probably change the name, because it's a terrible name. I'd also like to add something to the user's Start menu. So I'll go over here and create a new folder and call this one PixelSmith. Then I'm going to click here and choose Create New Shortcut. I would like the Primary output. Again, I'll rename this one. I'd also like a shortcut to my help file. So I'll add one more shortcut and pick Documents and then Documentation.chm. Now, I'm ready to build the application, rename that, and I'm ready to build.
I'll come over here and choose Build. Once I have a successful build, I'll go to my solution and choose Open Folder in Windows Explorer. It will open my installer application. Here is the files that it will give to my user. They can double-click on these, like the setup.exe, and now you see the dialog includes the text that I had, PixelSmith Desktop V2. It has my Readme file. It's suggesting the correct folder location based on the criteria I put in that Property window, the Lynda folder, and then the PixelSmithDesktop V2.
I'll click on Next to install, and I have now successfully installed my application. Next, I'll go to the Start menu and see if my application is here. It was called PixelSmith. There it is, PixelSmithDesktop. It's running successfully. Next, I'll try my Start folder, and I'll look for the PixelSmith folder, and both my shortcuts are available there, so I'll click on the Documentation.chm file to see what my help file looks like. That's working. If you were to go look in the Program Files folder on your hard drive, you'd also see those subfolders that I generated, like for instance the Samples folder is there.
I would like to show you how to uninstall the application. On Windows 7 you would go to Programs and Features, and then you're going to scroll down and find the PixelSmith area. There it is. Click on this and choose Uninstall. Click Yes to this dialog, and now the application is uninstalled. The Visual Studio Installer creates a basic setup that works for most developers. If you want more power, I suggest you look at the InstallShield add-in. There is one feature that's missing from this installer. I think it would be nice if the application would automatically update when you create a new version.
For that, you need to look at creating a ClickOnce installer, and that's the topic of the next movie in this chapter.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 102013 Viewers
61 Video lessons · 88729 Viewers
71 Video lessons · 72554 Viewers
56 Video lessons · 104194 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.