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:4.48 out of 5
 25 people have rated this page
Article Score18477
Comments    Submit Comment

Comment #1  (Posted by XTab on 09/22/2003)

I'm sure that many many members now and in for a long time to come in the future will be grateful for the time you've spent and trouble you've taken to write this article and provide the sample solution, George. It seems to be a problem area for lots of people - so hopefully your 'frustration-buster' will help get them back on track.
Nice job!
 
Comment #2  (Posted by Hugo newbie on 09/25/2003)

Hello, it is indeed a great tutorial, but I seem to have problems indicating the right path into which the "Custom Cursor" folder should be copied. I realized this after I tried to add the output file to the Custome Cursor Folder in the system file 'Installer sample' view. Can you please explain how to go about it?
Thanks in advance.
 
Comment #3  (Posted by Hugo newbie on 09/25/2003)

Got it! I look forward to your next tutorial.
Thanx.
 
Comment #4  (Posted by George Poth on 09/25/2003)

Great that you found a way to do it. But could you just explain what went wrong? Thanks.
 
Comment #5  (Posted by EDubs on 10/17/2003)

Dude, this article was exactly what I was looking for when I wanted a fast, no bs article on a win installer. Thanks a million George.
 
Comment #6  (Posted by Psychie on 10/22/2003)

Hi there,
Thanks for taking the time to write this tutorial but I was wondering if you had any more advanced tutorials to with Deployment. I'd like to be able to customize the setup program to include an option for installing the dotNetFramework in the setup. I'd also like to be able to incllude the ODBC and associated setings in the setup. Sound interesting?
A tutorial waiting to be written, I'd say!
Cheers!
 
Comment #7  (Posted by Amit Khanna on 11/12/2003)

Hi this sample is gr8 resource but kindly mention how to include dotnet framework within my Setup.msi ....
It would be a gr8 help...
thanks inadvance...
Amit
 
Comment #8  (Posted by Stan Loach on 01/16/2004)

Hello George:

Thanks for the great tutorial.

I have noticed that no matter what I do VB.NET seem to run much slower than an Access application using forms and sub forms. Everything I have created in Access or Excel appears to run so much quicker. This is particicularly noticeable with regard to reports (Access compared with Crystal Reports).

Is VB.NET generally much slower than access?

For instance it took approximately ten seconds for a Crystal Report to appear on screen from a click event, whereas an access report appeared in less than two seconds on the same machine.

I would really appreciate your thoughts on this matter

Kind regards,

Stan

 
Comment #9  (Posted by tuscan_sun on 03/05/2004)

Thanks for the article!!
 
Comment #10  (Posted by CaffeineJunkie on 05/09/2004)

Why are we required to incorporate the entire .Netfx pack. It's like 23 mb. My program is only 136kb. If i want people to download my program, why would they if they are forced to download an extra 23mb.. Think of all those people on 56k. Is there anyway to include only the portions of the dotnetfx package, like the ones you need..


Thanks.

/cj
 
Comment #11  (Posted by Chris Lane on 05/14/2004)

Great Article. I would like to know how to package or kick of more then one install packages, I need to package MDAC 2.8 with my application. I created an install package for my application and all I can find on MDAC 2.8 is it's own install package. Does anybody know how to do this?

Thanks,

Chris
 
Comment #12  (Posted by Fabio H. M. Medeiros on 05/18/2004)

Achei meio fraco este tutorial
Serve bem para um setup básico, mas faltam muitos recursos.
De qq forma, já é um começo. E está bem feito, bonitinho.
Aguardo algo mais completo...
 
Comment #13  (Posted by George Poth on 10/10/2004)

"Achei meio fraco este tutorial
Serve bem para um setup básico, mas faltam muitos recursos.
De qq forma, já é um começo. E está bem feito, bonitinho.
Aguardo algo mais completo..."

Let me first translate what you said, and then I will come back to it.

“I think this tutorial is weak. It’s okay for a basic setup, but it lacks many resources. Anyway, it is a beginning. It’s well-done, beautiful. I look forward to something more complete …”

The tutorial is not weak as it promises exactly what it delivers. You can always come up with something better. But I forgot: criticism comes easier than craftsmanship, as one member says in his signature.

And by the way, I find it very impolite that you post in another language than English. This is an American site and you should not post in Portuguese. Imagine I posted my articles in German. Now, to make sure you get what I’m writing, here comes my Portuguese version:

Este tutorial não é fraco por que trata os pontos anunciados. Você pode escrever algo melhor á qualquer momento. Más eu esqueci: critica é mais fácil do que trabalho, que um dos membros diz em sua assinatura.

Além disso, eu acho muito mal-educado postar numa língua que não seja inglês. Este é um site americano e você não deve postar em português. Imagine seu eu colocasse meus artigos em alemão. Agora para ter certeza que você entende, vou traduzir para português:

 
Comment #14  (Posted by an unknown user on 01/14/2005)
Rating
Straightforward with examples all the way.
 
Comment #15  (Posted by an unknown user on 01/31/2005)
Rating
Thanks, its indeed a very great effort.
I am looking forward for ur next article.
 
Comment #16  (Posted by Narsing on 01/31/2005)
Rating
Its great ! I sincerely appreciate your efforts,looking forward for your another article.
Narsing
 
Comment #17  (Posted by an unknown user on 03/02/2005)
Rating
what is the password for installer.zip
 
Comment #18  (Posted by Asad Naeem on 03/13/2005)
Rating
Simply the Best. I m looking for it
 
Comment #19  (Posted by an unknown user on 03/14/2005)
Rating
The tutorial was very easy to use & understand. I hope though, that you will consider doing a future version that is much more complicated and involved as I would like to see how to handle other install options (like registry changes, etc).
 
Comment #20  (Posted by an unknown user on 05/02/2005)
Rating
Because the files InstMsiAe.exe and InstMsiW.exe not include in my package installer?
antonio@e-idata.com.br
 
Comment #21  (Posted by Deebird on 05/31/2005)
Rating
Apparently :-)I wasn't they only one who had difficulty with this problem. Thanks for the trouble you've made making this explanation here. Good job!
 
Comment #22  (Posted by an unknown user on 06/23/2005)
Rating
Superb tutorial!!!
 
Comment #23  (Posted by an unknown user on 06/23/2005)
Rating
This article mentioned deploying the framework with an application briefly but did not explain how.
 
Comment #24  (Posted by Jaffer on 07/20/2005)
Rating
Hi,
Your article is really good for starters. I would like to know one thing. Could u tell me how can we write our custome code to execute on install and unistall time.
thnx
 
Comment #25  (Posted by an unknown user on 07/22/2005)
Rating
Good..
 
Comment #26  (Posted by David Anastasi on 07/25/2005)
Rating
Excellent article. Very straight forward and easy to understand.
The only thing I did not get was the error: "WARNING: This setup does not contain the .NET Framework ....." Why is this?
 
Comment #27  (Posted by an unknown user on 07/25/2005)
Rating
Its a fabulous article about installer and gives complete knowledge of "how to create installer". Thanx guys
 
Comment #28  (Posted by Saurabh Maheshwari on 08/24/2005)
Rating
It`s really a valuable for my work
Thanx
 
Comment #29  (Posted by Red_Special_K on 09/02/2005)
Rating
Straight to the point- working examples- sets out the question and then answers it! If only more articles were this way. This is a great starting point for my project & I have enough info to develop the rest from here. Really appreciate your work- Cheers!
 
Comment #30  (Posted by an unknown user on 10/25/2005)
Rating
It was very useful

 
Comment #31  (Posted by Naga on 02/14/2006)
Rating
That's useful article, but can anybody tell me how to create a shortcut in Control Panel using the windows installer - if so please let me know - nagarajan@i7asia.co.in
 
Comment #32  (Posted by an unknown user on 11/10/2006)
Rating
very useful, clear and informative
 
Comment #33  (Posted by an unknown user on 01/31/2007)
Rating
very effective and easy to understand
 
Comment #34  (Posted by an unknown user on 02/21/2007)
Rating
The Article is will written and the steps are really clear!
It helped me a lot.
Beside the man is funny!
It’s good to know that there are fun programmers out there! ^^
 
Comment #35  (Posted by an unknown user on 09/14/2007)
Rating
fajnie by bylo gdyby bylo to po polsku :P
 
Comment #36  (Posted by an unknown user on 01/31/2008)
Rating
Very well laid out and demonstrates to new users how easy it can be to use these large developemnt tools. Thanks very much.
 
Comment #37  (Posted by an unknown user on 03/21/2008)
Rating
This is a simple walkthrough that tells me exactly what i want to know
 
Sponsored Links