[WiX-users] Deployment Tools Foundation: ApplyPatch Method

2013-11-06 Thread Jeff Nielsen
I'm trying to use the DTF libraries to apply a Patch to an Msi file and then 
extract the updated files from the Patched Msi. I can't get it working, and I'm 
at wit's end. Any guidance would be much appreciated.

I can apply the patch and transform to the msi, and the Files table in the Msi 
then contains the updates from the patch. That seems good. I then try to use 
InstallerPackage.ExtractFiles to extract the files into a directory. When I get 
down to a file whose contents is in the CAB in the Patch (netfx.msp), I receive 
a "Stream Not Found: netfx_PCW_CAB_NDP" error. I can't figure out how to get 
the patch cab (PCW_CAB-NDP) into the Msi. I thought that 
InstallerPackage.ApplyPatch would do this, but apparently not. 

I'm using netfx.msi and netfx.msp that is in the \upgrades\netfx directory in 
the Win 7 distribution for my testing. Here's a shortened version of my code:

// define the variables
string msiPath = @"d:\upgrade\netfx\netfx.msi";
string mspPath = @"d:\upgrade\netfx\netfx.msp";
string transformName = "T320_1ToU1.MST";

// open the Msi file
using (InstallPackage package = new InstallPackage(msiPath, 
DatabaseOpenMode.Transact))
{
// open the Msp file
   using (PatchPackage patch = new PatchPackage(mspPath))
   {
// set the directories for the Msi file
   package.WorkingDirectory = unpackSubdirectory;
   package.SourceDirectory = 
System.IO.Path.GetDirectoryName(msiPath);

   // apply the patch
   package.ApplyPatch(patch, transformName);

   // query the list of files from the Msi
   List fileList = new 
List(package.ExecuteStringQuery("SELECT `File` FROM `File`", null));

   // loop through the files in the fileList
   foreach (String fileItem in fileList)
   {
// add the string to a FileArray
   string[] fileArray = { fileItem };

   // extract the files
   package.ExtractFiles(fileArray);
   }
}
}

>From the DTF Help file, I think that InstallPackage.Consolidate(mediaCabinet) 
>might be the answer, but I can't get that to work.

Thanks,
Jeff
--
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
___
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


[WiX-users] Deployment Tools Foundation: ApplyPatch Method

2013-11-07 Thread Jeff Nielsen
Blair et al,

Thanks for the info, but I'm still fairly well stuck. If the patch cab remains 
in the patch, it seems my code doesn't allow the InstallPackage.ExtractFiles 
method to find the patch's cab at extract time. This would make sense as to why 
I'm getting a Stream Not Found error.

Is there somewhere specific I need to place the patch file, or some 
method/property I need to call to allow the ExtractFiles method to be able to 
find the patch cab? I currently have the msi, the msi's exteernal cabs and the 
msp in the same directory, which is set as the InstallPackage.SourceDirectory.

Jeff
 

Date: Thu, 7 Nov 2013 13:38:23 +
From: Blair Murri 
Subject: Re: [WiX-users] Deployment Tools Foundation: ApplyPatch
Method
To: General discussion for Windows Installer XML toolset.

Message-ID: 
Content-Type: text/plain; charset="utf-8"

Applying the patch adds a row to the media table and changes the file table?s 
sequence numbers to reflect the patched files being in the patch?s cab. That 
cab will still be in the MSP file.

Blair


From: Jeff Nielsen
Sent: ?Wednesday?, ?November? ?06?, ?2013 ?10?:?32? ?PM
To: General discussion for Windows Installer XML toolset.

I'm trying to use the DTF libraries to apply a Patch to an Msi file and then 
extract the updated files from the Patched Msi. I can't get it working, and I'm 
at wit's end. Any guidance would be much appreciated.

I can apply the patch and transform to the msi, and the Files table in the Msi 
then contains the updates from the patch. That seems good. I then try to use 
InstallerPackage.ExtractFiles to extract the files into a directory. When I get 
down to a file whose contents is in the CAB in the Patch (netfx.msp), I receive 
a "Stream Not Found: netfx_PCW_CAB_NDP" error. I can't figure out how to get 
the patch cab (PCW_CAB-NDP) into the Msi. I thought that 
InstallerPackage.ApplyPatch would do this, but apparently not. 

I'm using netfx.msi and netfx.msp that is in the \upgrades\netfx directory in 
the Win 7 distribution for my testing. Here's a shortened version of my code:

// define the variables
string msiPath = @"d:\upgrade\netfx\netfx.msi";
string mspPath = @"d:\upgrade\netfx\netfx.msp";
string transformName = "T320_1ToU1.MST";

// open the Msi file
using (InstallPackage package = new InstallPackage(msiPath, 
DatabaseOpenMode.Transact))
{
   // open the Msp file
  using (PatchPackage patch = new PatchPackage(mspPath))
  {
// set the directories for the Msi file
  package.WorkingDirectory = unpackSubdirectory;
  package.SourceDirectory = 
System.IO.Path.GetDirectoryName(msiPath);

  // apply the patch
  package.ApplyPatch(patch, transformName);

  // query the list of files from the Msi
  List fileList = new 
List(package.ExecuteStringQuery("SELECT `File` FROM `File`", null));

  // loop through the files in the fileList
  foreach (String fileItem in fileList)
  {
   // add the string to a FileArray
  string[] fileArray = { fileItem };

  // extract the files
  package.ExtractFiles(fileArray);
  }
   }
}

> From the DTF Help file, I think that InstallPackage.Consolidate(mediaCabinet) 
> might be the answer, but I can't get that to work.

Thanks,
Jeff
--
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
___
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


[WiX-users] Deployment Tools Foundation: ApplyPatch Method

2013-11-12 Thread Jeff Nielsen
I think I've figured out why InstallPackage.ApplyPath method is failing for me, 
and I think this is a bug in the DTF code. Phil's comments got me thinking and 
I've done my best to debug what's going on in ApplyPatch. I'm a newbie on 
several levels here, so forgive me if I've missed something.

The ApplyPatch method does two basic things: 1) applies the transform to the 
database and 2) copies the patch cab from the patch and inserts it into the 
database. Applying the transform seems to work correctly, but the problem is in 
moving the patch cab into the database.

Before moving the cab, ApplyPatch creates a record for the patch cab in the 
Media table, using the string renamePatchCabinet  ("netfx_PCW_CAB_NDP" in my 
case)

string patchPrefix = Path.GetFileNameWithoutExtension(patchPackage.FilePath) + 
"_";
...
string renamePatchCabinet = patchPrefix + patchCabinet;
...
this.Execute("INSERT INTO `Media` (`DiskId`, `LastSequence`, `Cabinet`) VALUES 
({0}, '{1}', '#{2}')", renamePatchMediaDiskId, lastSeq, renamePatchCabinet);

When ApplyPatch inserts the cab into the database, the cab is named with the 
patchCabinet string ("PCW_CAB_NDP" in my case)

patchCabRec[1] = patchCabinet;
patchCabRec.SetStream(2, patchCabFile);
this.Execute("INSERT INTO `_Streams` (`Name`, `Data`) VALUES (?, ?)", 
patchCabRec);

So when I call InstallPackage.ExtractFiles, I get an error message "Stream Not 
Found: netfx_PCW_CAB_NDP", as the stream is actually named "PCW_CAB_NDP" in the 
database.

If I change: "patchCabRec[1] = patchCabinet;" to "patchCabRec[1] = 
renamePatchCabinet;",  InstallPackage.ExtractFiles will extract all this files 
without any errors.


On a related note, I'm having a challenge with InstallPackage.Commit(). If I 
instantiate InstallPackage with DatabaseOpenMode.Transact,

when I call InstallPackage.Commit(), I get a "function failed during execution" 
exception with the following StackTrace:

   at Microsoft.Deployment.WindowsInstaller.SummaryInfo.Persist()
   at Microsoft.Deployment.WindowsInstaller.Database.Commit() 
...

If I instantiate InstallPackage with DatabaseOpenMode.Direct, at the end of my 
using() I also get a "function failed during execution" exception with the 
following StackTrace:
   at Microsoft.Deployment.WindowsInstaller.SummaryInfo.Persist()
   at Microsoft.Deployment.WindowsInstaller.Database.Commit()
   at Microsoft.Deployment.WindowsInstaller.Database.Dispose(Boolean disposing)
   at Microsoft.Deployment.WindowsInstaller.InstallerHandle.Dispose()
...

Strangely, I can use instantiate Database with DatabaseOpenMode.Transact and 
Database.Commit() seems to work fine.  (I haven't tried Database with 
DatabaseOpenMode.Direct)

>From what I can tell in the source, InstallPackage.Commit() is inherited from 
>Database.Commit(), so I'm a bit perplexed. Any ideas?

  
Regards,
Jeff


Date: Fri, 8 Nov 2013 10:40:15 -0800
From: Phil Wilson 
Subject: Re: [WiX-users] Deployment Tools Foundation: ApplyPatch
Method
To: "General discussion about the WiX toolset."

Message-ID:

Content-Type: text/plain; charset=ISO-8859-1

It's not clear to me what that ApplyPatch method is doing under the covers.
It's not MsiApplyPatch(), because that does an install of the patch. It
appears to actually be MsiDatabaseAplyTransform() judging from the
transform parameter, and that just modifies the tables.

This might help:
http://blogs.msdn.com/b/heaths/archive/2006/02/14/532200.aspx

particularly where he mentions using MsiOpenDatabase on a patch file and
then looking for streams.

Phil Wilson
--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
___
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users