A common scenario is where you have a Basic MSI project and you want to copy files during the installation from one folder to another.  For whatever reason you don't want to do this by adding the files to a component and letting the installer do it.  So, you decide to do it manually using XCopyFile in a custom action.  Sounds great, right?

I have had mixed results using XCopyFile in a custom action.  A recent example is where I needed to copy a folder from a DVD.  This folder had thousands of file and lots of subdirectories.  I tried using XCopyFile in a custom action, but most of the time it would just copy the top level folder and files.  Through research I found that one way to get around this might be to create the folders first on the target machine and then copy the files, but who wants to do that?  Especially if you have a few thousand files to copy like I did.

The approach I settled on was to create a Managed Code Custom Action.  I passed the source and destination paths to a method in a C# class library, the files were copied and no more problems were had.

I am not sure why XCopyFile didn't work the way I expected.  I just got to the point where I had spent enough trying to use it, and when I went to the Managed Code Custom Action, the problem was solved and I could move on with my life.

Running a Custom Action During Uninstall in a Basic MSI Project

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • NewsVine
  • Reddit
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • Twitter
  • Technorati
  • Live
  • LinkedIn
  • MySpace

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Security Code: