Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Downloads | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » Deployment » Creating Setup and Deployment Projects in VS.NET

Creating Setup and Deployment Projects in VS.NET

This step-by-step tutorial guides you how to create a setup and deployment project using Visual Studio .NET to build a setup of your applications.

Technologies: .NET 1.0/1.1,Visual C# .NET
Total downloads :
Total page views :  260771
Rating :
 3.33/5
This article has been rated :  6 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
 
Become a Sponsor


Related EbooksTop Videos

Pocket PCs which run Windows CE 3.0, a version of Windows, is designed to be as compact and modular as possible. As a result, not all the features you've come to expect on a Windows PC are present - but a surprising number are available, including the Windows Script engines. JScript and Visual Basic Scripting Edition (VBScript) are available on all Pocket PCs to provide access to the script engines in applications such as Pocket Internet Explorer .

Pocket PC ships with a version of Internet Explorer, affectionately known as PIE (Pocket Internet Explorer). PIE has a bunch of interesting features, one of which is the ability to run script code in an HTML page. Because memory is at a premium on Pocket PCs, PIE allows only one
This step-by-step tutorial guides you how to create a setup and deployment project using Visual Studio .NET to build a setup of your applications. 

Even before we could get into the VS.NET mode of creating setups we will have a quick introduction on the need of automated setups.

Section I: Introduction

I-1: Why?

The First Question I would like to ask the development community is how many among us use a proper installer for deployment. The answer could well be very few since many would prefer the manual way of installation. Many teams overlook the need for proper automated installation; reason could well be no time allocation for the team to come up with automated installation plans. I can assure that one can reduce around 30-40% of post-installation issues if you plan for a proper automated installer. We will look on how to troubleshoot the origin of these issues in the next section.

I-2: Deployment Plans?

There are many topics that have to be thought about before releasing a plan for process of installation. Some of the critical questions to these issues are as follows:

Q: a) What do you want to deploy? Is it a Web application files setup, Client Desktop
Setup or a Database installation?

Q: b) What are the pre-installation Harware configuration i.e processor settings,
RAM, disk space etc; Software packages i.e MS Office, SQL Server Enterprise edition, etc that are mandatory for you to setup?

Q: c) Which are the physical paths for your custom files, system files, Database (.dat,
mdf etc), configuration files, read-write files? This is critical today since for us to be Windows 2003 compliant there are certain rules that have to be followed in this regard.

Q: d) What do you want to configure post-installation? These may include things like
configuring database connection string in your Web.config files; register the user via web by running a custom exe file etc.

Answers to the above points lead us to a sketchy definition of our deployment plan in general. If you were to analyze and answer the above points as a checklist;
For e.g.

Answer: a) Web Application
I need to figure out an installer that can set up webprojects. This will be my INSTALLER PROJECT TYPE.

Answer: b) Intel Pentium 566 Mhz, 256 MB RAM, 9 Gb HDD; Windows 2000 Enterprise edition, MS Office 2000, SQL Server 2000, MDAC 2.6, IIS 5.0.
Validation rules before continuing with the installation are now clear. These are my LAUNCH CONDITIONS.

Answer: c) All ASP files - WebFolder under WWWRoot; DLLs, Exe's Files - Bin Folder under Application path; Config files - Config folder under Userprofile folder (Usually config is specific to users).

Folder locations are now known, these will be my FOLDER/FILE SYSTEM on target machine.

Answer: d) Add a registry entry of database connection string, save the organization details that user entered during installation in a configuration file. The post-installation action items are my CUSTOM ACTIONS on the target machine.

From the analysis that we did just now we know what are the action items. There are many installer software's available but I would like to go the MSI way using VS.NET. Advantages are:
MSI has become an international standard for setups.

VS.Net has sufficient features to create a professional setup. Cost of ownership is low.

Section II: VS.NET Setup Projects

II-1: Project Types

There are five types of setup and deployment projects in VS.NET, but three are of significant importance that are "SetUp Project", "Web Setup Project" and "Merge Module Project".



Display 1: Project Type dialog.

  • Setup Project

    Generic type of project that could be used for all type of applications including web based application.

  • Web SetUp Project

    Name suggests the type; this project type helps in creating virtual directories for web based applications during installation. 

  • Merge Module Project

    When you want to install some additional third party software like MSDE along with your application then you can use this type of project. Use a *.msm extension based merge module installation of MSDE along with your own and create a setup.

II-2 Get Started

1) Select a SetUp Project type as shown in Display 1.

2) The default File System editor will appear in the window as shown in Display 2.



Display 2: Default File System Editor

3) One can add special folders here into which they intend to add files. Just right click on the editor to view the special folder types available. These are the folders into which you can drag and drop an entire folder structure with files.

4) Click on Registry editor and navigate to that editor (Display 3). One can configure registry settings here like "Manufacturer's name", "Version No", etc.

Display 3: Using registry editor

5) There is also Launch Conditions editor available. This is of greatest use since one can pre-validate for certain rules even before installation.

Validations can include file search, registry search, Component search or a particular deployment condition like as we mentioned earlier in section 1-2-b). Consider Display 4 where I added a Launch Condition and set the property condition as "PhysicalMemory>10000" i.e. 10GB and gave a custom error message "Physical Memory is less than 10GB." After the build when I tried to install it gave me error message as shown in Display 5 and cancelled the installation process, obviously my system had less than 5GB HD space and condition evaluated to false.

Note: For List of properties available go to MSDN help and search on Property Reference. There is a launch condition "MsiNetAssemblySupport" by default. This can be removed if computer on which your application is being installed does not support CLR.

Display 4: How to add condition to Launch condition.

Display 5: Launch validation!

6) File types editor is used to associate a default command action, File description , icon and extension for your custom files. There are many occasions we create new file-types with extensions like ".rmt" or ".cpg" etc. With the arrival of Win2k3 the rules specify that all files should have a default open command and an icon association. Please refer to display 7 and 8.

Note: Command association for the file is a must, hence need to associate an exe file.

Display 7: Configure default icon and extension for the file type.

Display 8 : Open command associated with the Notepad exe.

7) User Interface editor is provided in VS.Net by default with certain additional dialogs as per the requirements (refer display 9). Add for e.g. Textboxes (A) option that provides you with 4 textbox with edit value, label and property (Display 10). This is the most important editor since this is the UI that interfaces between the user and your MSI setup. The values captured from here are used throughout the installer like in Custom actions.



Display 9: Default view of User interface editor.

Display 10: See the EditLabel, EditProperty and Editvalue attributes.

Here if we pass the Editvalue as "Orbit-e", change EditLabel as Companyname and EditProperty as "COMPANYNAME"; in my custom actions section when I read the property "COMPANYNAME" it gives me "Orbit-e". This is the editor where in one can ask user to enter Company details, some configuration information like connectionstring for database etc.

8) Custom actions editor is where one adds some custom built *.exe, *.bat, *.wsh and other script files. As an example I have added a new C# windows application project as in Display 11. The following code in display that has a "Messagebox.Show" for a command line argument received. This could very well be any other functionality instead of Messsagebox.Show.



Display 11: Entry point has arguments to receive.

Once this is done, click Custom actions editor->Install->Add Custom action. This gives a dialog as shown below in display 12. Select Application folder->Add Output->Primary Output->Ok->Ok.



Display 12:Select application folder.

Now we are ready to pass the arguments for this primary output file as shown in Display 13. Pass the string [COMPANYNAME] in the "Arguments" (Pass multiple argument with some delimiter that is not a keyed character in same manner). Check "InstallerClass" property to False. This should be true only if this is a .Net installer class that can be used to programmatically access the MSI setup instances and databases. We will not discuss this since this is out of scope from this context.

Display 13: Configure the Custom action properties

NOTE: Refer to MSDN on types of custom actions and when are they fired, since this is crucial for your cleanup process in your un/installation.

9) Installer setup is now complete. Build the project and try to install. At one point in the installation process the setup throws up a Messagebox (Display 14) with the Winform and will continue only after this form is closed, since all these form part of a single installer session. This value was the same that was entered in the User Interface editor.

Display 14: Messagebox display from the Custom exe.

Note: There is one property that helps a lot that is [TARGETDIR] that gives the path where the user selected your application to install.

Conclusion

Though I have not been able to discuss complete technical features of VS.NET to create MSI, the features discussed in this article with some individual reading are very much sufficient to create a professional MSI installer. Installers are helpful for your deployment process but are not the only thing that affects this process; proper versioning of your assembly/dll's is also of primary importance. Happy Programming!


Login to add your contents and source code to this article
 [Top] Rate this article
 About the author
 
Vishnu Prasad
I am working as Associate Consultant (Technical), Orbit-e Consulting-Bangalore. Expertise in MS based technologies like VB6, ASP, COM+, SQL 2K, C#, ADO. Net, ASP. Net.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Microsoft Visual Studio 2010 offers more to developers than any other Visual Studio release. Work more productively and collaboratively-with greater control over your work at every step. The Beta 2 can give you a head start on achieving efficiency.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
Powerful ASP.NET Hosting w/ NO Setup Fees. Click Here!
Become a Sponsor
 Comments