Manually modifying the XML Files Changes in InstallShield

Source: Internet
Author: User

Having been busy packing the installer recently, using InstallShield 15, the packaging process encountered a small problem (suspected to be InstallShield 15 bug), but it took me a night to solve the problem.

When you use InstallShield to create an installer to build a asp.net web site, you need to make some changes to the property values in Web.config, such as connection String, which you need to change to:

Data Source=[is_sqlserver_server];D atabase=[is_sqlserver_database];uid=[is_sqlserver_username];p wd=[is_ Sqlserver_password]

Where Is_sqlserver_server, Is_sqlserver_database, Is_sqlserver_username, Is_sqlserver_password are the property values entered by the user during installation. In order to achieve Web.config changes, you can use the XML Files in InstallShield Changes, but I found a problem, according to the database default, the user name is SA, the password is empty, if the above mentioned connection String directly into the value of the attribute is connectionstring, because the Is_sqlserver_password is null, the final installation result, In the web.config is: connectionstring= "", all become empty? But if you don't add "Pwd=[is_sqlserver_password", everything is fine, that is, because the property is empty, it causes the entire value to become empty. I suspect a bug in InstallShield 15.

The final solution is as follows:

First step:

Create a new Property:[connection_string in Property manager and add Web.config to the XML Files changes in configuration-> connectionstrings-> add[@connectionString = "Data source=;D atabase=;uid=sa;pwd=" and @name = "Dbstr"], add an item, Attribute:connectionstring,value for just created property:[connection_string]

Step Two:

To add a script to the InstallScript:

function ChangeProperty(hMSI)
    STRING svConStr,svServer,svDBName,svUID,svPWD;
    NUMBER nRet;
begin
    nRet=128;
    MsiGetProperty(hMSI,"IS_SQLSERVER_SERVER",svServer,nRet);
    MsiGetProperty(hMSI,"IS_SQLSERVER_DATABASE",svDBName,nRet);
    MsiGetProperty(hMSI,"IS_SQLSERVER_USERNAME",svUID,nRet);
    MsiGetProperty(hMSI,"IS_SQLSERVER_PASSWORD",svPWD,nRet);
    svConStr="Data Source="+svServer+";DataBase="+svDBName+";uid="+svUID+";pwd="+svPWD;
    MsiSetProperty(hMSI,"CONNECTION_STRING",svConStr);
end;

Step Three:

Add a new action in the custom Actions and sequences, for example, called Setconnetionstring,function name ChangeProperty, and set its execution order to after Installinitialize.

The end is done! After the experiment, the result connectionString the value is expected, such as: connectionstring= "Data source=sqlserver;database=db;uid=sa;pwd="

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.