Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
576 views
in Technique[技术] by (71.8m points)

windows installer - Copy if not exist in WiX

I have a config file, myapp.exe.config, that I want to install only if it does not already exist. That is, I don't want to overwrite any existing config file. How can this be done in WiX?

(Ultimately I will have to do something more sophisticated with settings, having defaults and overrides and so on. But in the meantime I am just looking for a short-term fix.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What you describe is the default behavior if the file is the keypath of a component. For example, the following component will not be installed if foo.config already exists (or in the case of a versioned file, if a file with a equal or higher version number already exists):

<Component Id="foo.config">
   <File Source="foo.config"/>
</Component>

Note that if you have multiple files in your component, then only one can be the keypath. You can control this by setting the KeyPath attribute of the file to yes. But the recommended strategy is to have only one file per component, in which case the file automatically becomes the component keypath.

edit: note that this default behavior can be overridden with the REINSTALLMODE property. You may want to open your MSI with orca and see if this property is being set in the property table.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...