Wix - how to prevent overwrite entire directory?

后端 未结 2 1996
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-15 20:07

I have wix installer and it copies some files to some directories. Each file is declared as single component, with some path - if directory does not exist, installer will cr

相关标签:
2条回答
  • 2021-01-15 20:54

    In regards to how to avoid the timing issue with the property being set before cost finalize, another reliable way to deal with it is to write the properties to registry.

    I believe this is the most common work around to the timing issues with properties getting set, and it allows the installer to keep track of those properties for uninstalls, etc... I've used it to great effect.

    Here is a good article by Rob Mensching on how to do that to get you started.

    0 讨论(0)
  • 2021-01-15 20:56

    Is there any condition (something like "is directory exist") that I can use here?

    Yes, you can use a Condition element like this:

    <Directory Id="FooFolder" Name="Foo">
        <Component Id="SomeId">
            <File Source="..." />
            <Condition>Not FOO_FOLDER_ALREADY_EXISTS</Condition>
        </Component>
    </Directory>
    

    The kind of things that you can use as a condition are explained in the Conditional Statement Syntax documentation of windows installer.

    In this case, I believe you can set the FOO_FOLDER_ALREADY_EXISTS property with a DirectorySearch like this:

    <Property Id="FOO_FOLDER_ALREADY_EXISTS">
        <DirectorySearch Id="FooFolderSearch" Path="[FooFolder]" />
    </Property>
    

    edit: apparently the directory search above doesn't work because the [FooFolder] property is only resolved during the CostFinalize action (see documentation). But the directory search already happens before that during the AppSearch action.

    I am unsure how to work around that. It would probably involve setting the FOO_FOLDER_ALREADY_EXISTS property after CostFinalize with a custom action instead of a windows installer directory search.

    0 讨论(0)
提交回复
热议问题