Install SQL Server as prerequisite

Need help authoring your installer? Ask the community for tips and advice.
Umarlone
Posts: 12
Joined: Mon Oct 23, 2017 7:15 pm

Install SQL Server as prerequisite

Postby Umarlone » Mon Oct 23, 2017 7:23 pm

Hello Advance Installer guys, you guys have truly done a great job, very well done. Question, how to install SQL express and once its installed get its connection string and update asp.net settings file which is a json file. Its an asp.net core app. Everything else is working fine and doing it nicely like installing .net core sdk and configuring IIS etc. We want to have prerequisite of SQL server and install it then update settings file accordingly. Your help will highly appreciated.. Thank you

Sorin
Posts: 587
Joined: Mon May 08, 2017 1:03 pm

Re: Install SQL Server as prerequisite

Postby Sorin » Tue Oct 24, 2017 12:01 pm

Hello and welcome to our Forums,

Unfortunately currently we do not support operations on JSON files. In order to implement your scenario you need to write your own custom action that will edit the JSON file.

For example, you can create your custom action as a custom action written in C# or a custom action written in C++.

You can also use the VBScript or a PowerShell custom action to implement this functionality.

This custom action could be scheduled to run in "Install Execution Stage". This will ensure the custom action that edit the JSON file will run afer the SQL Server Express will be installed (which should be configured as a feature-based prerequisite).

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Umarlone
Posts: 12
Joined: Mon Oct 23, 2017 7:15 pm

Re: Install SQL Server as prerequisite

Postby Umarlone » Tue Oct 24, 2017 6:36 pm

Thank you for your reply. It is not clear as to how to write the logic, because I don't know how it will run. All i need is after post install a pop up comes up, where user enters server ip, port, database and take these inputs and insert into a json settings file thats in root directory. Installer does not need to install SQL Server. Can you share insights as to what is the procedure of writing custom action. Many Thanks

Umarlone
Posts: 12
Joined: Mon Oct 23, 2017 7:15 pm

Re: Install SQL Server as prerequisite

Postby Umarlone » Wed Oct 25, 2017 2:26 am

so the following code as ddl loaded to advance installer, how can I link this to a dialog where user can insert these values and it updates the json file :
[CustomAction]
public static ActionResult CustomAction1(Session session)
{

var ip = session["GK_IP_ADDRESS"];
var port = session["GK_PORT"];
var instance = session["GK_SQL_INSTANCE"];
var databaseName = session["GK_DATABASE"];
var integratedSecurity = session["GK_Integrated_Security"];
var username = session["GK_USERNAME"];
var password = session["GK_PASSWORD"];

session.Log("Begin CustomAction1");
string json = File.ReadAllText("C:\\Program Files (x86)\\Your Company\\Your Application\\RTLSWeb1\\appsettings.json");
dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
jsonObj.ConnectionStrings.DefaultConnection = $"Server=tcp:{ip},{port}\\{instance};Initial Catalog={databaseName};" +
$"Integrated Security={integratedSecurity};User ID={username};Password={password};Connection Timeout=3000;";
string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText("C:\\Program Files (x86)\\Your Company\\Your Application\\RTLSWeb1\\appsettings.json", output);
return ActionResult.Success;
}

Sorin
Posts: 587
Joined: Mon May 08, 2017 1:03 pm

Re: Install SQL Server as prerequisite

Postby Sorin » Wed Oct 25, 2017 10:22 am

Hello,

In order to "link" the custom action to a dialog you could use the method described here : How to execute a custom action when a button is pushed

Please let me know if you have any other questions.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Umarlone
Posts: 12
Joined: Mon Oct 23, 2017 7:15 pm

Re: Install SQL Server as prerequisite

Postby Umarlone » Wed Oct 25, 2017 5:50 pm

Thank you . I think support for asp.net core should be added to software . Well most of the work can be done what is already in advanced installer , works fine even for asp.net core apps except the json files . I am sure you guys already realise , hardly anyone touches old asp.net anymore . It's all about .net core now. Thank you for help.

Sorin
Posts: 587
Joined: Mon May 08, 2017 1:03 pm

Re: Install SQL Server as prerequisite

Postby Sorin » Thu Oct 26, 2017 1:22 pm

Hello,

Thank you for your suggestion. This improvement is already added on our TODO list. I've increased its priority and will be available in a future version of Advanced Installer.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Umarlone
Posts: 12
Joined: Mon Oct 23, 2017 7:15 pm

Re: Install SQL Server as prerequisite

Postby Umarlone » Mon Oct 30, 2017 8:00 am

Ahh God, this is so much time on a single button. I have a dialog box that has three textboxes and I have tested powershell to edit a file, the problem is when I go to dialog> click on Next button>published events> new> " new control event" window pop,when I click on Execute custom action, the argument dropdown has nothing in it, not event my custom action. All i want is take the values form textboxes and pass these vales to powershell and powershell will update the file which should be there after installation of app. Thank you

Sorin
Posts: 587
Joined: Mon May 08, 2017 1:03 pm

Re: Install SQL Server as prerequisite

Postby Sorin » Mon Oct 30, 2017 9:04 am

Hello,

I have a dialog box that has three textboxes and I have tested powershell to edit a file, the problem is when I go to dialog> click on Next button>published events> new> " new control event" window pop,when I click on Execute custom action, the argument dropdown has nothing in it, not event my custom action

Please note that the dropdown you've mentioned only displays custom actions without sequence. The custom actions from "Wizard Dialogs Stage" or "Install Execution Stage". Please make sure your custom action is configured without sequence.
However this workflow will trigger the launch of the powershell script when the button is pressed. Is this what you need to achieve?

All i want is take the values form textboxes and pass these vales to powershell and powershell will update the file which should be there after installation of app

In order to get the Windows Installer properties associated with your editboxes and use them in your poweshell scripts please use the method described in this article: How to set an installer property using custom actions

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Umarlone
Posts: 12
Joined: Mon Oct 23, 2017 7:15 pm

Re: Install SQL Server as prerequisite

Postby Umarlone » Mon Oct 30, 2017 6:21 pm

Yes thank you , got, cant figure out how to show dialog after installation is complete because json file will not there if it executes first..

Umarlone
Posts: 12
Joined: Mon Oct 23, 2017 7:15 pm

Re: Install SQL Server as prerequisite

Postby Umarlone » Tue Oct 31, 2017 12:50 am

All is working well now, except I dont have access to the folder where app was installed. If I manually create a folder on desktop and give read and write access to the folder then installer does all, creates json file in the folder, otherwise powershell gets permission denied error.

Sorin
Posts: 587
Joined: Mon May 08, 2017 1:03 pm

Re: Install SQL Server as prerequisite

Postby Sorin » Tue Oct 31, 2017 9:25 am

Hello,

This issue seems to be triggered by the fact that your power shell custom action runs without elevation. If this custom action runs after "Preparing" in "Install Execution Stage" you could set it to run "When the system is being modified (deferred) with "Run under the LocalSystem with full privileges (no impersonation) option enabled.

If you need to run this custom action before "Preparing", you could elevate the whole installation process by using "Run as administrator" option from "Install Parameters" page. Please note that this option requires the EXE package type.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Umarlone
Posts: 12
Joined: Mon Oct 23, 2017 7:15 pm

Re: Install SQL Server as prerequisite

Postby Umarlone » Thu Nov 02, 2017 6:46 pm

Hello there, all is working well so far except when i build .exe , the installation UI is fine but when I build MSI it breaks like color,text alignments etc. Any thoughts? Thanks

Sorin
Posts: 587
Joined: Mon May 08, 2017 1:03 pm

Re: Install SQL Server as prerequisite

Postby Sorin » Fri Nov 03, 2017 8:42 am

Hello,

Please note that our Themes feature requires Enhanced User Interface which is only available on EXE package type. If you use a theme other than the Classic one and set the package type to MSI the Enhanced UI will be disabled, thus the interface will not be properly displayed.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube


Return to “Building Installers”

Who is online

Users browsing this forum: Google [Bot] and 1 guest