Hi,
After having the app.config & the Setup Project, to do this we need to:
1.- Rigth click in Setup Project -->Add-->Project Output-->Primary output
2.- Right click again & View User Interface
3.- In User Interface, at Start Node, Right Click & Add Dialog, Select the one fill your needs
4.- View the properties of Dialog Added and make visible only the controls you need filling the Editlabels, the one important is the EditProperty's to access it from an Installer Class.
5.- Rigth click in Setup Project-->View-->Custom Actions
6.- Rigth click in Custom Actions --> Add Custom Action-->Application Folder
7.- Select the primary output of Install node and view their properties, at CustomActionData set the Dialog Added properties into Vars space separated like:
/TARGETDIR="[TARGETDIR]\" (ending with backslash in directories & between quotation marks).
/DBDIR=[DBDIR].
8.- Right click in the project where the app.config is and Add-->New Item->General (Installer Class).
9.- At the Installer class we need to override the Install method to do that we need (filling the app.config values from the installation parameters) like:
public override void Install(System.Collections.IDictionary stateSaver)
{base.Install(stateSaver);
string targetDirectory = Context.Parameters["targetdir"];
string param1 = Context.Parameters["DBDIR"];
string exePath = string.Format("{0}Myapp.exe", targetDirectory);
Configuration config = ConfigurationManager.OpenExeConfiguration(exePath);
config.AppSettings.Settings["DBDir"].Value = param1;
config.Save();
}
10.- Save & Rebuild
11.- Test it.
Greetings.
No hay comentarios:
Publicar un comentario