我在安装新版本之前正在执行主要升级和卸载现有产品.但我想保留现有的配置文件.
由于早期版本没有Permanent ="yes",它会在卸载时删除配置文件.
我怎么能做这样的事情在卸载之前将'app.config'复制为'app.config.bak'.卸载后将其从"app.config.bak"恢复为"app.config".
<DirectoryRef Id="INSTALLDIR">
<Component Id="BackupConfigComponent" Guid="87368AF7-4BA2-4302-891A-B163ADDB7E9C">
<CopyFile Id="BackupConfigFile" SourceDirectory="INSTALLFOLDER" SourceName="app.config" DestinationDirectory="INSTALLFOLDER" DestinationName="app.config.bak" />
</Component>
</DirectoryRef>
<DirectoryRef Id="INSTALLDIR">
<Component Id="RestoreConfigComponent" Guid="87368AF7-4BA2-4302-891A-B163ADDB7E9C">
<CopyFile Id="RestoreConfigFile" SourceDirectory="INSTALLFOLDER" SourceName="app.config.bak" DestinationDirectory="INSTALLFOLDER" DestinationName="app.config" />
</Component>
</DirectoryRef>
<InstallExecuteSequence>
<Custom Action="BackupConfigFile" After="InstallInitialize" />
<RemoveExistingProducts After="InstallInitialize" />
<Custom Action="RestoreConfigFile" After="InstallInitialize" />
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)
谢谢
wix ×1