わかりました、この回答は最新のインストーラー フレームワーク (3.2.2) に基づいています。古いバージョンで機能するかどうかはわかりません。
ターゲット ディレクトリを上書きするには、構成ファイルでRemoveTargetDirを false に設定するだけです。
<RemoveTargetDir>false</RemoveTargetDir>
出来た。
公式ドキュメントでは、この要素を次のように説明しています。
アンインストール時にターゲット ディレクトリを削除しない場合は、false に設定します。
使い方がわからない場合は、少し混乱します。
bool TargetDirectoryPage::validatePage()
{
m_textChangeTimer.stop();
if (!isComplete())
return false;
if (!isVisible())
return true;
///
/// NOTICE HERE:
/// If you set RemoveTargetDir to false, function return true here.
const QString remove = packageManagerCore()->value(QLatin1String("RemoveTargetDir"));
if (!QVariant(remove).toBool())
return true;
const QString targetDir = this->targetDir();
const QDir dir(targetDir);
// the directory exists and is empty...
if (dir.exists() && dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty())
return true;
const QFileInfo fi(targetDir);
if (fi.isDir()) {
QString fileName = packageManagerCore()->settings().maintenanceToolName();
#if defined(Q_OS_MACOS)
if (QInstaller::isInBundle(QCoreApplication::applicationDirPath()))
fileName += QLatin1String(".app/Contents/MacOS/") + fileName;
#elif defined(Q_OS_WIN)
fileName += QLatin1String(".exe");
#endif
QFileInfo fi2(targetDir + QDir::separator() + fileName);
///
/// AND NOTICE HERE:
/// Do exists check here.
if (fi2.exists()) {
return failWithError(QLatin1String("TargetDirectoryInUse"), tr("The directory you selected already "
"exists and contains an installation. Choose a different target for installation."));
}
return askQuestion(QLatin1String("OverwriteTargetDirectory"),
tr("You have selected an existing, non-empty directory for installation.\nNote that it will be "
"completely wiped on uninstallation of this application.\nIt is not advisable to install into "
"this directory as installation might fail.\nDo you want to continue?"));
} else if (fi.isFile() || fi.isSymLink()) {
return failWithError(QLatin1String("WrongTargetDirectory"), tr("You have selected an existing file "
"or symlink, please choose a different target for installation."));
}
return true;
}
「NOTICE HERE:」というコメントに注意してください。