Remove file during minor upgrade

前端 未结 2 1331
盖世英雄少女心
盖世英雄少女心 2020-12-21 06:48

I have one feature with several components. One components contains dynamic linked files in a directory. When I delete one file in that directory, build the setup, and run t

2条回答
  •  时光说笑
    2020-12-21 07:30

    Chris has described the method I normally use to fix such a problem. However, I find that a quicker approach is to rename the parent folder for the dynamically linked files. Just changing from MyFolder to My Folder will work - or any other name for that matter. The reason is that you de-couple the old files from the new ones. You no longer point to the same absolute paths, and MSI reference counting hence removes all old files correctly. And you need a major upgrade for this to work correctly like Chris says.

    A very good summary of what is required for a minor upgrade to work (as well as other details): http://www.installsite.org/pages/en/msi/updates.htm

    From the above site: "If you remove a file or registry key from a component, you must populate the RemoveFile or RemoveRegistry table respectively to delete the orphaned resource.". This might also work, but I would not use this approach.

    Personally I would avoid dynamic file linking altogether. I have never been able to use dynamically linked files without it resulting in a problem. Generally they have been update and patching problems, but also other kinds. It really is not a good feature to use. Rather you should take the opportunity with the folder name change to add all files statically.

    You can find more details on MSI component reference counting here: https://stackoverflow.com/a/1422121/129130

    So in summary here is what I would do:

    • Create backup of your installation project
    • Delete all dynamically linked files
    • Modify the name of the parent directory that used to hosts dynamically linked files. For example from MyFiles to My Files will do.
    • Re-add all dynamically linked files with static components

提交回复
热议问题