Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2005
    Posts
    2

    Huh? Setting web.config

    As part of my setup, I ran a web install script that installs a virtual directory and a dot.net web application. This application has a web.config file that contains a string @@CONNECTSTRING@@ that I want to replace with a data connect string. I can set up the form with the database server, user name, password, and database, but need to find this file after it has been installed on the web server and edit this file by replacing the above placeholder with a valid connect string.

    I can't see how to do this in setup factory?

    HELP.

  2. #2
    Join Date
    May 2000
    Location
    Indigo Rose Software
    Posts
    2,150
    To find the file and get the path to it use File.Find

    To dump this file to a workable string use: TextFile.ReadToString

    Then to find where that certain string is use: String.Find

    You should be able to replace the text and everything using the String actions.

    Adam Kapilik

  3. #3
    Join Date
    Dec 2006
    Posts
    5

    Grin Any further assistance

    Hi,

    I am also trying to achieve the same outcome. Although my syntax, taken from above appears to be correct at the end of the installation the strings within the web.config file do not change.

    This is my code,

    config = File.Find("%AppFolder%", SessionVar.Expand("%AppFolder%\\Web.config"), false, false, nil, nil);
    testtostring = TextFile.ReadToString(SessionVar.Expand("%AppFolde r%\\Web.config"));
    SQLServerName = String.Replace("@@SQLServer@@", "x", "%SQLServer%", false);
    DBName = String.Replace("@@DatabaseName@@", "X", "%CGiXDatabase%", false);

    The %SQLServer% and %CGiXDatabase% are parameters entered during the setup by the user via an edit fields screen.

    Any help would be much appreciated as i am still getting to grips with this.

    Thanks in advance.

  4. #4
    Join Date
    Dec 2006
    Posts
    5
    IN addition to the above this is the log file out put

    [01/04/2007 15:21:25] Error Script: On Post Install, [1]: config = File.Find("%AppFolder%", SessionVar.Expand("%AppFolder%\\Web.config"), false, false, nil, nil); (1002)

  5. #5
    Join Date
    May 2000
    Location
    Indigo Rose Software
    Posts
    2,150
    Any time that you use a %type% variable in script you need to use SessionVar.Expand(). I see in your code you have this action in some places but not in others.

    Adam Kapilik

  6. #6
    Join Date
    Dec 2006
    Posts
    5

    Huh? Still no luck.

    HI Adam,

    Thanks you so much for the reply. I have changed my code to the following

    Code:
    config = File.Find(SessionVar.Expand("%AppFolder%"), SessionVar.Expand("%AppFolder%\\Web.config"), false, false, nil, nil);
    Application.GetLastError ()
    testtostring = TextFile.ReadToString(SessionVar.Expand("%AppFolder%\\Web.config"));
    Application.GetLastError ()
    SQLServerName = String.Replace("@@SQLServer@@", "@@SQLServer@@", SessionVar.Expand("%SQLServer%"), false);
    Application.GetLastError ()
    DBName = String.Replace("@@DatabaseName@@", "@@DatabaseName@@", SessionVar.Expand("%CGiXDatabase%"), false);
    Application.GetLastError ()
    With the same results. I also added in the .GetLastError() function but again no errors were returned and the log file was empty. Could there be something wrong with the string that i am searching for within the file? These are the strings i am trying to search and change:-

    <add key="sqlServer" value="@@SQLServer@@" />
    <add key="sqlDatabase" value="@@DatabaseName@@" />

    I have also attached a screenshot of where i have setup the session variables. These relate to an edit fields screen that asks for input during the installation.
    Attached Images

  7. #7
    Join Date
    Dec 2006
    Posts
    5

    Talking Got it!

    Adam,

    Thanks for your help but i have now managed to achieve the outcome. Didnt realise there was an examples tab in the help section. This helped a lot and with some minor tweeking and a few debugging lines i have achieved it.

    The code for reference by others is below.

    Thanks again,
    Stu


    Code:
    -- **************************** WEB.CONFIG **********************************************
    -- Find the Web.Config 
    FindWebConfig = File.Find(SessionVar.Expand("%AppFolder%"), SessionVar.Expand("%AppFolder%\\Web.config"), false, false, nil, nil);
    
    -- Read the contents of Web.Config into a string.
    Webconfig = TextFile.ReadToString(SessionVar.Expand("%AppFolder%\\Web.config"));
    Dialog.Message("config = ", Webconfig, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    
    -- Check the error code.
    error = Application.GetLastError();
    -- If an error occurred, display the error message.
    if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    else
        -- Replace every occurrence of the string "@@SQLServer@@" with the string entered in the setup for the SQL Server.
        SQLServer_Name = String.Replace(Webconfig, "@@SQLServer@@", SessionVar.Expand("%SQLServer%"), false);
    
        -- Write out the modified contents of Web.Config.
        TextFile.WriteFromString("%AppFolder%\\Web.config", SQLServer_Name, false);
        
    Webconfig2 = TextFile.ReadToString(SessionVar.Expand("%AppFolder%\\Web.config"));
    
         -- Replace every occurrence of the string "@@SQLServer@@" with the string entered in the setup for the SQL Server.
        Database_Name = String.Replace(Webconfig2, "@@DatabaseName@@", SessionVar.Expand("%CGiXDatabase%"), false);
    
        -- Write out the modified contents of Web.Config.
        TextFile.WriteFromString("%AppFolder%\\Web.config", Database_Name, false);
    
    Webconfig3 = TextFile.ReadToString(SessionVar.Expand("%AppFolder%\\Web.config"));
    
    Dialog.Message("Web.Config = ", Webconfig3, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    
        -- Check the error code.
        error = Application.GetLastError();
        -- If an error occurred, display the error message.
        if (error ~= 0) then
            Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
        end
    end

  8. #8
    Join Date
    Mar 2008
    Posts
    1

    Talking Setting web.config

    any info how to auto config a webconfig file

Similar Threads

  1. Global Slider Control Setting
    By kmartin7 in forum AutoPlay Media Studio 5.0
    Replies: 2
    Last Post: 02-23-2004, 06:53 PM
  2. Setting my Application to Expire After Thirty Days
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 10-01-2003, 02:45 PM
  3. Setting Page Transition Effects
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 09-24-2003, 01:08 PM
  4. INFO: Setting Environment Variables
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-10-2002, 12:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts