Updating the String from the plain text file while installing.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Updating the String from the plain text file while installing.

Raghu12
This post has NOT been accepted by the mailing list yet.
I have a requirement to pass plain text file to MSI.
Before Installing the application, set few parameters like environment variables and connection string. Update the text file according to the local system environment and pass this file to MSI as an input.

config.txt:
Ex: FQDN=abc-def@ghi.com
replace_String=asdf

Product.wxs:
<Property Id="FQDN"/>

<Directory Id="ADMIN" Name="Admin">
              <Component Id="PathComp" Guid="get-GUID">
                <CreateFolder />
                <util:XmlFile Id="SetKey1" Action="setValue" File="[ADMIN]Web.config"
                              ElementPath="//appSettings/add[\[]@key='URLAddress'[\]]/@value"
                              Value="[FQDN]"
                              SelectionLanguage="XPath" Sequence="1" />
              </Component>
                              </Directory>

Command-line:
SampleOne.msi TRANSFORMS=config.txt

When I'm executing the above command it is giving an error:
MSI (c) (54:44) [13:59:26:947]: Unable to create a temp copy of transform ''.
MSI (c) (54:44) [13:59:26:947]: Note: 1: 2203 2:  3: -2147287037
MSI (c) (54:44) [13:59:26:947]: Couldn't find cached transform . Looking for it at the source.
MSI (c) (54:44) [13:59:26:947]: Looking for secure file transform: config.txt
MSI (c) (54:44) [13:59:26:947]: Original transform ==> config.txt
MSI (c) (54:44) [13:59:26:947]: Transform we're running from ==> config.txt
MSI (c) (54:44) [13:59:26:947]: Note: 1: 2203 2: config.txt 3: -2147286960
DEBUG: Error 2203:  Database: config.txt. Cannot open database file. System error -2147286960
1: 2203 2: config.txt 3: -2147286960
Error applying transforms. Verify that the specified transform paths are valid.
config.txt
MSI (c) (54:44) [13:59:26:947]: Note: 1: 1708
MSI (c) (54:44) [13:59:26:947]: Product: SampleOne -- Installation failed.

If this is the right approach, let me know where I'm making mistake.
Otherwise could you help in achieving this.

I could do this from command prompt but my requirement is to have a human readable file.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Updating the String from the plain text file while installing.

Namrata
This post has NOT been accepted by the mailing list yet.
<Util:XmlFile/> is used and worked only with XML files and not for plain text as per Installation protocol  only config files are required to be changed. If somehow you need to change  a plain text file you need to write a customaction dll in dot net as follows :
[CustomAction]
public static ActionResult SearchAndReplaceInit(Session session)
{
  session.Log("Begin SearchAndReplaceInit");
  File.Delete(SearchAndReplaceDataFile);
  if (session.Database.Tables.Contains("SearchAndReplace"))
  {
     var lstSearchAndReplace = new List<SearchAndReplaceData>();
     using (var propertyView =
      session.Database.OpenView("SELECT * FROM `SearchAndReplace`"))
     {
       propertyView.Execute();
       foreach (var record in propertyView)
       {
         var token = new SearchAndReplaceData
         {
           File = session.Format(record["File"].ToString()),
           Search = session.Format(record["Search"].ToString()),
           Replace = session.Format(record["Replace"].ToString())
         };
         lstSearchAndReplace.Add(token);
       }
     }
     var serializer = new TypedXmlSerializer<List<SearchAndReplaceData>>();
     serializer.Serialize(SearchAndReplaceDataFile, lstSearchAndReplace);
  }
  else
  {
    session.Log("No SearchAndReplace custom table found");
  }
  session.Log("End SearchAndReplaceInit");
  return ActionResult.Success;
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Updating the String from the plain text file while installing.

Raghu12
This post has NOT been accepted by the mailing list yet.
Thanks Namrata. Its working.
Loading...