Moving over from VS 2008 Web Setup Project - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

jmace
Posts: 55
Joined: Thu Jul 01, 2010 4:46 pm

Moving over from VS 2008 Web Setup Project

I am moving over from Visual Studio 2008 Web setup projects with some custom actions. In my setup project, I have a dialogue that collects SQL Server login credentials. The project then uses those credentials with SMO to create the login, database, and user. The custom action also goes out to a server and gets a bunch of scripts that builds tables, views, functions, and stored procedures.

I was just wondering what would be the easiest way to go about doing this with Advanced Installer. I'm not quite sure whether I should import my solution, which doesn't seem to work with web development projects, or to just start from scratch.

I would like to reuse as much code as possible but I'm not sure how to go about using the values from the Advanced Installer custom dialog boxes with my Custom Action that inherits from the Installer class. Currently, I am using Context.Parameters [<ParameterName>]. In order to get these values I have to pass in, as Custom Action Data, something like this: /Server= [PropertyName] where I could refer to the index Server as Context.Parameters ["Server"] to retrieve this value when using the built-in Visual Studio setup projects.

Any ideas would be greatly appreciated.

Jim
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Moving over from VS 2008 Web Setup Project

Hi Jim,

Advanced Installer easily supports a variety of custom actions. DLL custom actions might be something you are interested in. So you can make a DLL out of your code and use that as a custom action. The Forum and the user guide contain details on using DLL custom actions. We also support SQL Scripts and even have a predefined SqlConnectionDialog for collecting connection data.

You might also want to follow our simple and professional tutorials to get you started in using Advanced Installer.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
jmace
Posts: 55
Joined: Thu Jul 01, 2010 4:46 pm

Re: Moving over from VS 2008 Web Setup Project

I have the SQL script and SQL custom dialog box stuff figured out. I just need to figure out how to tie in my custom action that edits my web application's connection string. Is there a built-in way to do this or do I need to use my custom action?

Can you direct me to where I can get some information on how to use properties in my custom actions?

This is my method for configuring my connection string when I use a web setup project with a custom action that inherits from the Installer class:

private void ConfigureDatabaseConnectionString() {
//set variables
String targetSite = Context.Parameters["TargetSite"];
String targetVDir = Context.Parameters["TargetVDir"];
String conKey = "TrackerDBConnectionString";

// Open Application's Web.Config
System.Configuration.Configuration config =
WebConfigurationManager.OpenWebConfiguration("/" + targetVDir);

// Add new connection string setting for web.config
ConnectionStringSettings appDatabase = new ConnectionStringSettings(conKey,
td.ApplicationConnectionString);

//check for TrackerDBConnectionString
if (config.ConnectionStrings.ConnectionStrings[conKey] == null) {
//create new connection string
config.ConnectionStrings.ConnectionStrings.Clear();
config.ConnectionStrings.ConnectionStrings.Add(appDatabase);
}
else {
//update existing key
config.ConnectionStrings.ConnectionStrings[conKey].ConnectionString = appDatabase.ConnectionString;
}


// Persist web.config settings
config.Save();
}

Any help would be greatly appreciated.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Moving over from VS 2008 Web Setup Project

Hello,

Properties can be passed to your .net installer class through the use of parameters in a .net installer class custom action.

The parameters can then be accessed from your code by using:

Code: Select all

Context.Parameters["ParameterName"].ToString()
Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
jmace
Posts: 55
Joined: Thu Jul 01, 2010 4:46 pm

Re: Moving over from VS 2008 Web Setup Project

Gabriel,

True. Where do I set/get those parameters in Advanced Installer? As you can see from the above code snippet, I need to get the relative path for the application's Web.config selecting change the connection string properties. I take it from your reply, I use the same objects to get the properties from Advanced Installer with my Custom Action?

Jim
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Moving over from VS 2008 Web Setup Project

Hi Jim,

Gabriel forgot to tell you that the file web.config can be imported in Advanced Installer because it is a standard XML file, this is done in the Files and Folders page.
After you have imported the file you can edit is using our built-in editor for XML files and use the properties set in the SQL dialog to update the content of the XML file at run-time.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”