Should the App.Config be a companion file to the application or go in its own component?
When I create a Windows Installer package (say using WiX) and I install the application App.exe
as well as the App.exe.config
should the config file have its own component or should it be a companion file to the application executable?
<Component Id="C.App.exe">
<File Source="App.exe"/>
</Component>
<Component Id="C.App.exe.config">
<File Source="App.exe.config"/>
</Component>
versus
<Component Id="C.App.exe" Guid="PUT-GUID-HERE">
<File Id="F.App.exe" Source="App.exe"/>
<File Source="App.exe.config" CompanionFile="F.App.exe"/>
</Component>
If I install different App.exe.config
files depending on some external property (say run-time environment like test or开发者_如何学Go release) does that affect what choice I should make?
The answer is it depends. Rob's article mentioned by Yan is a good read, here is another:
Defining Installer Components http://msdn.microsoft.com/en-us/library/aa368269(VS.85).aspx
The trick is to understand how costing and repairs are based on keyfiles, how the default versioning rules work, how you plan on servicing your application in the future and making your decision based on that.
It is recommended to put a single resource (file, registry key, etc.) into a single component. In this case this resource is a KeyPath of the component. Windows Installer watches the key path of each component to decide if it worth installing, repairing, upgrading, etc.
This article of Rob Mensching explains the things in detail.
精彩评论