Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  The Installer
 »  Home  »  Deployment  »  The Installer
The Installer
by George Poth | Published  09/20/2003 | .NET Newbie Deployment | Rating:
George Poth

I have been teaching English in Brazil since 1994 and always wanted to do more for learners than common textbooks can offer. This started with web sites that couldn't reach most students as computers and the Internet are not standard for most people in this country.

Computer tools to help Brazilian students learn a complex language like English are practically non-existent and so I sent some suggestions to software companies. Since Brazil is neither a target market for English textbooks nor for software of this kind, the rejection seemed natural.

As a result, I tried some free developer tools such as Borland's free C++ compiler, Free Pascal, and Envelope's Visual Basic. Envelope's Visual Basic, which is a Microsoft Visual Basic 1.0 clone and still available, suited my taste but I knew it was obsolete technology. In March 2003, I bought a copy of Microsoft Visual Basic .NET Standard and have been hopelessly contaminated with the programming virus ever since.

I mostly write programs for educational purposes. Having discovered the wonderful world of DirectX recently, I am diving into the most entertaining part of programming: games. One can connect teaching with pure entertainment, learning, and culture.

 

View all articles by George Poth...
The Installer

Article source code: installer.zip

Sooner or later you want to get your stuff on a different machine. It's a pretty simple thing - if you know how to do it. If you don't, you might catch yourself head-banging. I mean, not to the rhythm of heavy metal; it's more like having some "bloody" spots on the wall - and on your shoulders something that once was called a head.

The first time I wanted to make an installer, I used the extraordinarily bad help system. Yes, I know, it's the second time I've grumbled about this. But hey, they could have used the time to write something helpful. Every time I press the F1 key, a nightmare begins. I sometimes even wonder what the F might stand for; but I don't think I have to go into details here.

If you have hard coded paths, the installer does not guarantee that your program will work on a different computer the way it works on yours. There is actually a great chance for things to go wrong, like for example, if a user installs your program in a different directory, like F:\ - c'mon, it really seems to be an omen.

A good way to work around this problem is to use "Application.StartupPath" in your code. The startup path is the folder where the .exe of your program is. During development, the bin folder is the application startup path. All files you want the program to deal with must be there. I have included a sample application that deals with this issue. It is certainly a good idea to look at the code.

The Making of "Setup"

When you open the bin folder of the provided sample program, you will see the three items as shown in Figure 01. The "point2" is a custom cursor and must be included in this folder.

(Figure 01)

Go back to the "Custom Cursor" folder. This should look like Figure 02.

(Figure 02)

Double click the solution to open it. From the file menu, point to "Add Project" and click "New Project" on the fly-out menu as Figure 03 indicates.

(Figure 03)

In the "Add New Project" window, choose "Setup and Deployment Projects" in the left pane and rename it to something appropriate. If you name it "Custom Cursor", you will receive an error message because it's already the name of the project. Since the name must be unique, I usually add the version number. In this case, it could be "Custom Cursor (v. 1.0.0.0)". I named this one "Installer Sample" as you can see in Figure 04. It is also the name that will appear later in the Add/Remove Programs window in the Control Panel. Click "OK" to open the deployment project.

(Figure 04)

When the project is open, the window should look like Figure 05.

(Figure 05)

Right click the "Application Folder" in the "File System (Installer Sample)", point to "Add" and then click "Folder" in the fly-out menu as Figure 06 indicates.

(Figure 06)

As this is the "Company Folder", you should rename it accordingly. In my case, I just used my name. Right click the "Company Folder" and add another folder, which is the program folder, and rename it "Custom Cursor". The file system should now look like Figure 07.

(Figure 07)

Right click the "Custom Cursor" folder, point to "Add" and then click "Project Output" in the fly-out menu. The next window will look like Figure 08.

(Figure 08)

Just to check that everything is going to be fine, you should see "Custom Cursor" as the project, the primary output should be selected, and the configuration should be set to "(Active)". When this is so, click "OK".

Right click the application folder again and choose to add a file. Browse to the bin folder and double click the cursor file. Repeat this step to add the program icon.

Your file system should now look like Figure 09

(Figure 09)

Right click the "primary output" and choose "Create shortcut …". Rename the shortcut to "Custom Cursor" and click somewhere to confirm the change. Click the shortcut once and browse for your program icon in the application folder from the Properties window as Figure 10 shows. The icon is not visible in the system files, but it will be in the program.

(Figure 10)

If you want to create a shortcut on the desktop, move the shortcut you just created to the "User's Desktop" folder by dragging it there. Create a second shortcut and drag it to the "User's Programs Menu" folder. Just don't forget the icon.

Click the application folder once and go to the Properties window. Change the default location from [ProgramFilesFolder][Manufacturer]\[ProductName] to the following:[ProgramFilesFolder][George Poth]\[Custom Cursor]. Of course, the name must be the name you used when you renamed the "Company Folder", and the program folder must be the same name you used when you renamed the program folder.

Click the "Installer Sample" in the Solution Explorer. There are some changes you should make in the Properties window according to the following table:

Property:Changes to be made:
AddRemoveProgramsIconBrowse for the program icon in the application folder.
AuthorYour name.
DescriptionWrite a short description if you want.
ManufacturerYour name.
ManufacturerYour website, pay attention to the required format: (http://www.myweb.com) or your e-mail (mailto:me@myweb.com)
SubjectAdditional information about the application.
SupportPhoneYour support phone number.
SupportURLA website with support/help.

From the build menu, choose "Build Installer Sample". When you're through, choose "Install" from the project menu. When the installation is complete, you will see the program in the menu (Figure 11) and on your desktop (Figure 12).

(Figure 11)

(Figure 12)

Open the Control Panel and go to Add/Remove Programs. You will see the program installed as Figure 13 shows.

(Figure 13)

Click the Installer Sample and open the information about support. You will see Figure 14. You could click the link to send an e - mail or to go to the author's web, depending on what changes you made in the Properties window.

(Figure 14)

In the IDE, change the solution configurations from Debug to Release, as Figure 15 shows.

(Figure 15)

From the Build menu, click Build Installer Sample as Figure 16 indicates.

(Figure 16)

When you're through with that, have a look at the output window as shown in Figure 17. Among other things, you will find this line: "WARNING: This setup does not contain the .NET Framework which must be installed on the target machine by running dotnetfx.exe before this setup will install. You can find dotnetfx.exe on the Visual Studio .NET 'Windows Components Update' media. Dotnetfx.exe can be redistributed with your setup." That means that you must install the same version of the .NET Framework on a user's computer with which you have compiled your application before you can install your program. You could distribute it with your CD; or at least give the user the link to download it. However, if you tell your user to download the framework, make sure he/she knows which version to download. The Microsoft Visual Basic .NET Edition 2002 needs version 1.0, and the Edition 2003 needs version 1.1. If the same version of the framework is already installed on the user's computer, the .NET Framework Setup will tell them so. Both .NET Framework versions can be installed on the same machine.

(Figure 17)

Now that you have the installer, open the Visual Studio Projects folder. If you have installed Microsoft Visual Basic .NET in the default location, then the folder should be here: C:\Documents and Settings\UserName\My Documents\Visual Studio Projects (This path might be different on other operating systems than XP).

Open the Installer Sample folder, and inside this folder, the Release folder. You will see the items as in Figure 18. The selected item in Figure 18 is your installer. On other operating systems than XP, you might have to look for the file extension (Installer Sample.msi). This is the file you need to copy to a media so as to install it on another computer.

(Figure 18)

Double-click the installer and you will see the Welcome Screen as in Figure 19.

(Figure 19)

Click "Next" to go to the next window in which you can arrange the installation as Figure 20 shows.

(Figure 20)

Click next to see the window in which you have to confirm the installation as you can see in Figure 21.

(Figure 21)

Click next to install as shown in Figure 22.

(Figure 22)

When the setup is complete you will see Figure 23.

(Figure 23)

Click "Close" to exit. The program is now installed. To uninstall or repair the program, you can use the Add/Remove Programs window in the Control Panel, or you could repeat the installation process.

At this place, I'd like to thank Ged Mead (XTab). Not only for of his invaluable help on this article, but also for his important help and his patience throughout the past seven months during which we have been in touch.

Related devCity.NET articles:

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:3.57692307692305 out of 5
 52 people have rated this page
Article Score28595
Sponsored Links