我正在进行重大升级,并在安装新版本之前卸载现有产品。但我希望保留现有的配置文件。
由于早期版本没有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>
谢谢