[wix-users] Deployment Tools Foundation Documentation: Working with Install Packages

Costanzo Ferraro c.ferraro at list-group.com
Fri Feb 2 04:00:54 PST 2018


Hi Joseph,

here is the complete code:

private void UpdateInstaller(string SetupFile, string SourcePath)
         {
             string fName;

             InstallPackage db = null;


             try
             {
                 string[] filesToUpdate = Directory.GetFiles(SourcePath);

                 if (filesToUpdate.Length > 0)
                 {
                     db = new InstallPackage(SetupFile, 
DatabaseOpenMode.Transact);

                     db.WorkingDirectory = 
Path.Combine(Path.GetTempPath(), "PkgTmp");
Directory.CreateDirectory(db.WorkingDirectory);

                     InstallPathMap files = db.Files;


                     foreach (string szKey  in files.Keys)
                     {
                         InstallPath path = files[szKey];
                         string binName = path.SourceName;

                         int i = binName.IndexOf('|');
                         string name = binName.Substring(i + 1);

                         bool fnd = filesToUpdate.Any(s => 
s.EndsWith(name));

                         if (fnd)
                         {
                             fName = filesToUpdate.First(s => 
s.EndsWith(name));
                             string DestFile = 
Path.Combine(db.WorkingDirectory, name);

                             File.Copy(fName, DestFile, true);

                             files[szKey].SourceName = name;
}
                     }

                     db.UpdateFiles();
                     db.Commit();

                     Directory.Delete(db.WorkingDirectory, true);
                 }
             }
             finally
             {
                 if (db != null)
                     db.Close();
             }
         }

Anyway, db.UpdateFiles() fails. What is the reason?



On 1/31/2018 4:43 PM, Joseph L. Casale via wix-users wrote:
> This is not even valid code, the path in your using directive is an error.
> You also don’t provide the type that 'files' is, it looks like a dictionary and if so, what is the value type, object? Cast to a string?
>
> Hard to help here without all the actual code...
>
>> -----Original Message-----
>> From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf
>> Of Costanzo Ferraro via wix-users
>> Sent: Wednesday, January 31, 2018 3:18 AM
>> To: wix-users at lists.wixtoolset.org
>> Cc: Costanzo Ferraro <c.ferraro at list-group.com>
>> Subject: [wix-users] Deployment Tools Foundation Documentation: Working
>> with Install Packages
>>
>> Dear List,
>>
>> I would like to update some files in a Product layout.   I tried to run
>> the example posted on DTF Documentation
>>
>>
>>       using (InstallPackage pkg = new InstallPackage("d:\builds\product.msi",
>>           DatabaseOpenMode.Transact))
>>
>>       {
>>           pkg.WorkingDirectory = Path.Combine(Path.GetTempFolder(),
>> "pkgtmp");
>>           foreach (string fileKey in files.Keys)
>>
>>     {
>>               string sourceFilePath = files[fileKey];
>>               string destFilePath = pkg.Files[fileKey].SourcePath;
>>               destFilePath = Path.Combine(pkg.WorkingDirectory,
>> destFilePath);
>>               File.Copy(sourceFilePath, destFilePath, true);
>>
>>         }
>>           pkg.UpdateFiles(new ArrayList(files.Keys));
>>
>>        pkg.Commit();
>>           Directory.Delete(pkg.WorkingDirectory, true);
>>
>> }
>>
>> but compiler signaled type mismatch error to these lines:
>>
>>
>> string sourceFilePath = files[fileKey];
>>
>> pkg.UpdateFiles(new ArrayList(files.Keys));
>>
>>
>> How can I fix them?
>>
>> Regards,
>>
>>
>> __________________________________________________________
>> __________
>> WiX Toolset Users Mailing List provided by FireGiant
>> http://www.firegiant.com/
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list