Click here to Skip to main content
11,720,557 members (68,593 online)
Click here to Skip to main content
Add your own
alternative version

dotNetInstaller - Setup Bootstrapper for .NET Application

, 4 Jan 2004 MIT 604.1K 1.8K 309
With this tool the developer can define the application prerequisites and install the correct version of these components in the correct order based on the user operating system type and language, allow the user to download these components from the web or install these components directly.
dotnetinstaller_source.zip
dotNetInstaller_source
dotNetInstaller
dotNetInstaller.vcproj.vspscc
dotNetInstaller.vssscc
mssccprj.scc
res
banner.bmp
dotNetInstaller.ico
dotNetInstaller.manifest
Thumbs.db
vssver.scc
Tools
vssver.scc
vssver.scc
InstallerEditor
App.ico
banner.bmp
bin
Release
InstallerEditor.exe
SourceLibrary.dll
vssver.scc
InstallerEditor.csproj.user
InstallerEditor.csproj.vspscc
InstallerEditor.suo
InstallerEditor.vssscc
mssccprj.scc
References
SourceLibrary.dll
vssver.scc
Thumbs.db
vssver.scc
Sample
banner.bmp
dotNetInstaller.exe
SupportFiles
DataAccess
Jet
Jet40Sp7
Win2000_English
Win2000_Italiano
Win9x_NT
WinME
WinXp_English
WinXp_Italiano
MDAC2.7Sp1Refresh
Win_98_ME_NT_2000
dotNet
v1.1
English
Italiano
InternetExplorer
IE60SP1_English
IE60SP1_Italiano
ServicePack
2000_SP4_English
2000_SP4_Italiano
NT4_SP6a_English
NT4_SP6a_Italiano
Win98_Y2k_Update_English
Win98_Y2k_Update_Italiano
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Xml;

namespace InstallerEditor
{
	/// <summary>
	/// node:configuration, type=install
	/// </summary>
	public class SetupConfiguration : Configuration
	{
		public SetupConfiguration():this("APPLICATION_NAME")
		{
		}
		public SetupConfiguration(string p_ApplicationName):base("install")
		{
			if (LanguageUI.Language == SupportedLanguage.Italian)
			{
				m_cancel_caption = "Chiudi";
				m_dialog_bitmap = "#APPPATH\\banner.bmp";
				m_dialog_caption = p_ApplicationName + " Installer";
				m_dialog_install_next = "Avanti";
				m_dialog_install_skip = "Annulla";
				m_dialog_message = "Per installare " + p_ApplicationName + " e' necessario aggiornare questi componenti:";
				m_failed_exec_command_continue = "Impossibile installare %s. Continuare l'installazione?";
				m_install_caption = "Installa";
				m_installation_completed = "Installazione di " + p_ApplicationName + " completata !";
				m_installing_component_wait = "Installazione di %s in corso. Attendere, l'operazione potrebbe richiedere alcuni minuti ...";
				m_reboot_required = "Per completare l'installazione e' necessario riavviare il computer. Riavviare ora?";
				m_reinstallflag_caption = "Reinstalla tutti i componenti";
				m_status_installed = " (Installato)";
				m_status_notinstalled = "";
			}
			else //english
			{
				m_cancel_caption = "Close";
				m_dialog_bitmap = "#APPPATH\\banner.bmp";
				m_dialog_caption = p_ApplicationName + " Installer";
				m_dialog_install_next = "Next";
				m_dialog_install_skip = "Cancel";
				m_dialog_message = "In order to install " + p_ApplicationName + " you must first upgrade this components:";
				m_failed_exec_command_continue = "Failed to install %s. Continue with others components?";
				m_install_caption = "Install";
				m_installation_completed = p_ApplicationName + " installed successfully !";
				m_installing_component_wait = "Installing %s . Wait, this operation could take some time ...";
				m_reboot_required = "To continue the installation you must restart your computer. Restart now?";
				m_reinstallflag_caption = "Reinstall all components";
				m_status_installed = " (Installed)";
				m_status_notinstalled = "";
			}
		}

		#region Attributes
		private string m_dialog_caption;
		private string m_dialog_message;
		private string m_dialog_bitmap;
		private string m_install_caption;
		private string m_cancel_caption;
		private string m_reinstallflag_caption;
		private string m_status_installed;
		private string m_status_notinstalled;
		private string m_failed_exec_command_continue;
		private string m_installation_completed;
		private string m_dialog_install_next;
		private string m_dialog_install_skip;
		private string m_installing_component_wait;
		private string m_reboot_required;

		[Description("Main dialog title. (REQUIRED)")]
		public string dialog_caption
		{
			get{return m_dialog_caption;}
			set{m_dialog_caption = value;}
		}
		[Description("Main message of the main dialog. (REQUIRED)")]
		public string dialog_message
		{
			get{return m_dialog_message;}
			set{m_dialog_message = value;}
		}
		[Description("Bitmap file used in the left panel of the main dialog. If this file doesn't exist or this attribute is empty the application load the bitmap from the .exe resource. Can contains path constant (see Help->Path Constant). (OPTIONAL)")]
		public string dialog_bitmap
		{
			get{return m_dialog_bitmap;}
			set{m_dialog_bitmap = value;}
		}
		[Description("Caption of the Install button. (REQUIRED)")]
		public string install_caption
		{
			get{return m_install_caption;}
			set{m_install_caption = value;}
		}
		[Description("Caption of the Cancel button. (REQUIRED)")]
		public string cancel_caption
		{
			get{return m_cancel_caption;}
			set{m_cancel_caption = value;}
		}
		[Description("Caption for the 'Reinstall all check box'. (REQUIRED)")]
		public string reinstallflag_caption
		{
			get{return m_reinstallflag_caption;}
			set{m_reinstallflag_caption = value;}
		}
		[Description("The string used for indicating an installed component. (OPTIONAL)")]
		public string status_installed
		{
			get{return m_status_installed;}
			set{m_status_installed = value;}
		}
		[Description("The string used for indicating a not installed component. (OPTIONAL)")]
		public string status_notinstalled
		{
			get{return m_status_notinstalled;}
			set{m_status_notinstalled = value;}
		}
		[Description("The message used when a component cannot be installed and ask if the application can continue with others components (Yes/No message). Must contain one '%s' string where the application put the description of the component. (REQUIRED)")]
		public string failed_exec_command_continue
		{
			get{return m_failed_exec_command_continue;}
			set{m_failed_exec_command_continue = value;}
		}
		[Description("Installation completed message. (REQUIRED)")]
		public string installation_completed
		{
			get{return m_installation_completed;}
			set{m_installation_completed = value;}
		}
		[Description("Caption for the next button. (REQUIRED)")]
		public string dialog_install_next
		{
			get{return m_dialog_install_next;}
			set{m_dialog_install_next = value;}
		}
		[Description("Caption for the skip button. (REQUIRED)")]
		public string dialog_install_skip
		{
			get{return m_dialog_install_skip;}
			set{m_dialog_install_skip = value;}
		}
		[Description("The message used when installing a component. Must contain one '%s' string where the application put the description of the component. (REQUIRED)")]
		public string installing_component_wait
		{
			get{return m_installing_component_wait;}
			set{m_installing_component_wait = value;}
		}
		[Description("The message used when the application need to restart and ask if restart now (with a Yes/No message). (REQUIRED)")]
		public string reboot_required
		{
			get{return m_reboot_required;}
			set{m_reboot_required = value;}
		}
		#endregion

		protected override void OnXmlWriteTagConfiguration(XmlWriterEventArgs e)
		{
			base.OnXmlWriteTagConfiguration (e);
			
			e.XmlWriter.WriteAttributeString("dialog_caption",m_dialog_caption);
			e.XmlWriter.WriteAttributeString("dialog_message",m_dialog_message);
			e.XmlWriter.WriteAttributeString("dialog_bitmap",m_dialog_bitmap);
			e.XmlWriter.WriteAttributeString("install_caption",m_install_caption);
			e.XmlWriter.WriteAttributeString("cancel_caption",m_cancel_caption);
			e.XmlWriter.WriteAttributeString("reinstallflag_caption",m_reinstallflag_caption);
			e.XmlWriter.WriteAttributeString("status_installed",m_status_installed);
			e.XmlWriter.WriteAttributeString("status_notinstalled",m_status_notinstalled);
			e.XmlWriter.WriteAttributeString("failed_exec_command_continue",m_failed_exec_command_continue);
			e.XmlWriter.WriteAttributeString("installation_completed",m_installation_completed);
			e.XmlWriter.WriteAttributeString("dialog_install_next",m_dialog_install_next);
			e.XmlWriter.WriteAttributeString("dialog_install_skip",m_dialog_install_skip);
			e.XmlWriter.WriteAttributeString("installing_component_wait",m_installing_component_wait);
			e.XmlWriter.WriteAttributeString("reboot_required",m_reboot_required);

			e.XmlWriter.WriteStartElement("components");
			foreach(Component c in Components)
			{
				c.ToXml(e.XmlWriter);
			}
			e.XmlWriter.WriteEndElement();
		}

		protected override void OnXmlReadTagConfiguration(XmlElementEventArgs e)
		{
			base.OnXmlReadTagConfiguration (e);

			if (e.XmlElement.Attributes["cancel_caption"] != null)
				m_cancel_caption = e.XmlElement.Attributes["cancel_caption"].InnerText;

			if (e.XmlElement.Attributes["dialog_bitmap"] != null)
				m_dialog_bitmap = e.XmlElement.Attributes["dialog_bitmap"].InnerText;

			if (e.XmlElement.Attributes["dialog_caption"] != null)
				m_dialog_caption = e.XmlElement.Attributes["dialog_caption"].InnerText;

			if (e.XmlElement.Attributes["dialog_install_next"] != null)
				m_dialog_install_next = e.XmlElement.Attributes["dialog_install_next"].InnerText;

			if (e.XmlElement.Attributes["dialog_install_skip"] != null)
				m_dialog_install_skip = e.XmlElement.Attributes["dialog_install_skip"].InnerText;

			if (e.XmlElement.Attributes["dialog_message"] != null)
				m_dialog_message = e.XmlElement.Attributes["dialog_message"].InnerText;

			if (e.XmlElement.Attributes["failed_exec_command_continue"] != null)
				m_failed_exec_command_continue = e.XmlElement.Attributes["failed_exec_command_continue"].InnerText;

			if (e.XmlElement.Attributes["install_caption"] != null)
				m_install_caption = e.XmlElement.Attributes["install_caption"].InnerText;

			if (e.XmlElement.Attributes["installation_completed"] != null)
				m_installation_completed = e.XmlElement.Attributes["installation_completed"].InnerText;

			if (e.XmlElement.Attributes["installing_component_wait"] != null)
				m_installing_component_wait = e.XmlElement.Attributes["installing_component_wait"].InnerText;

			if (e.XmlElement.Attributes["reboot_required"] != null)
				m_reboot_required = e.XmlElement.Attributes["reboot_required"].InnerText;

			if (e.XmlElement.Attributes["reinstallflag_caption"] != null)
				m_reinstallflag_caption = e.XmlElement.Attributes["reinstallflag_caption"].InnerText;

			if (e.XmlElement.Attributes["status_installed"] != null)
				m_status_installed = e.XmlElement.Attributes["status_installed"].InnerText;

			if (e.XmlElement.Attributes["status_notinstalled"] != null)
				m_status_notinstalled = e.XmlElement.Attributes["status_notinstalled"].InnerText;

			XmlNodeList l_List = e.XmlElement.SelectNodes("components/component");
			foreach (XmlElement l_XmlComp in l_List)
			{
				if (l_XmlComp.Attributes["type"] != null)
				{
					Component l_Comp;
					if (l_XmlComp.Attributes["type"].InnerText == "msi")
						l_Comp = new ComponentMsi();
					else if (l_XmlComp.Attributes["type"].InnerText == "cmd")
						l_Comp = new ComponentCmd();
					else if (l_XmlComp.Attributes["type"].InnerText == "openfile")
						l_Comp = new ComponentOpenFile();
					else
						throw new ApplicationException("Invalid type");

					l_Comp.FromXml(l_XmlComp);

					Components.Add(l_Comp);
				}
				else
					throw new ApplicationException("Type cannot be null");
			}
		}


		private ComponentCollection m_Components = new ComponentCollection();
		public ComponentCollection Components
		{
			get{return m_Components;}
			set{m_Components = value;}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

Davide Icardi
Software Developer
Italy Italy
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150901.1 | Last Updated 5 Jan 2004
Article Copyright 2003 by Davide Icardi
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid