1

我正在使用 InstallShield 2012 Spring - Premier Edition,并且在再次运行安装脚本时,我正在尝试用新安装脚本中的任何内容替换我们软件的现有安装(如果存在)。

我在网上阅读了一些关于配置次要和主要升级设置的内容。

我有一个 InstallScript 项目,但我找不到如何进行 Minor 和 Major 升级,就像使用 Basic MSI 项目一样。我在网上读到,这可以通过 MSI 项目来完成,方法是转到 Installation Designer,然后是 Media/Upgrades,然后配置升级。此选项在 InstallScript 项目中不可用。

我可以在 InstallScript 项目中使用什么来改变这种行为?先感谢您。

4

1 回答 1

0

我相信您需要在主脚本中添加更多事件处理程序。首先,您需要添加以下处理程序(如果它们尚不存在):

  • OnShowUI
  • OnUpdateUIBefore
  • OnUpdateUIAfter
  • OnMaintUIBefore
  • OnMaintUIAfter

重要的是要有 OnShowUI 才能运行适当的“之前”方法。以下是我的工作;您需要在其他方法中执行您需要执行的任何操作(我的方法非常特定于域,我无法直接提供这些方法)。

//---------------------------------------------------------------------------
// OnShowUI
//
// This function drives the UI sequence and file transfer of the setup.
// 
// The OnShowUI event is called directly by the framework to initiate
// the UI sequence and file transfer of the setup. By default this event
// displays UI that informs the end user that the maintenance setup has been
// completed successfully.
//---------------------------------------------------------------------------
function OnShowUI()
    BOOL bMaintenanceMode, bUpdateMode;
    string szIgnore, szTitle;
    LIST listDirs;
    number nFindAllDirsResult, nFindAllFilesResult;
    BOOL lDirEmpty;

begin
    // Enable dialog caching
    Enable( DIALOGCACHE );

    // Determine what events to show
    bUpdateMode = FALSE;
    bMaintenanceMode = FALSE;

    // Remove this to disabled update mode
    if (UPDATEMODE) then
        // checking to make sure app still exists in orig location
        if Is(PATH_EXISTS, TARGETDIR) then
            // Also check for empty TargetDir
            lDirEmpty = IsTargetDirEmpty();

            if (lDirEmpty) then
                // TARGETDIR is completely empty, so disable UPDATE mode
                bUpdateMode = FALSE;
            else
                // TARGETDIR has some contents, so continue with UPDATE
                bUpdateMode = TRUE;
            endif;
        else
            // Turn off Update mode if original folder is gone
            bUpdateMode = FALSE;
        endif;

        if (!bUpdateMode) then
            // If Update mode is set but the original target is missing
            // need to flag the installer to force full reinstall (otherwise it will 
            // think all features have already been installed (by analyzing the log))
            FeatureReinstall();
        endif;
    endif;

    // Remove this to disable maintenance mode.
    if (MAINTENANCE) then
        // checking to make sure app still exists in orig location
        if Is(PATH_EXISTS, TARGETDIR) then
            // Also check for empty TargetDir
            lDirEmpty = IsTargetDirEmpty();

            if (lDirEmpty) then
                // TARGETDIR is completely empty, so disable Maint mode
                bMaintenanceMode = FALSE;
            else
                // TARGETDIR has some contents, so continue with Maint
                bMaintenanceMode = TRUE;
            endif;
        else
            // Turn off maintenance mode if original folder is gone
            bMaintenanceMode = FALSE;
        endif;

        if (!bMaintenanceMode) then
            // If Maintenance mode is set but the original target is missing
            // need to flag the installer to force full reinstall (otherwise it will
            // think all features have already been installed (by analyzing the log))
            FeatureReinstall();
        endif;
    endif;

    // Show appropriate UI

    if( bUpdateMode ) then
        OnUpdateUIBefore();
    else
        if ( bMaintenanceMode ) then
            OnMaintUIBefore();
        else
            OnFirstUIBefore();
        endif;
    endif;

    // Move Data
    OnMoveData();

    if( bUpdateMode ) then
        OnUpdateUIAfter();
    else
        if ( bMaintenanceMode ) then
            OnMaintUIAfter();
        else
            OnFirstUIAfter();
        endif;
    endif;

    // Disable dialog caching
    Disable(DIALOGCACHE);
end;

我会说,在 OnUpdateUIBefore 中,我注释掉了以下代码:

// Check whether the update is needed.
if( nResult = VERSION_COMPARE_RESULT_SAME ) then
    // Note: This result should occur only for differential media, since the setup
    // will display OnMaintUIBefore or OnFirstUIBefore by default if the versions match
    // for full setup media.
    szMsg = SdLoadString( IDS_IFX_WARNING_UPDATE_NOT_NEEDED );
    SdSubstituteProductInfo( szMsg );
    if( MessageBox( szMsg, MB_ICONEXCLAMATION | MB_YESNO ) != IDYES ) then
        abort;
    endif;
endif;

我不记得为什么,但我怀疑它导致更新模式无法按预期工作。

我自动化了我的 Installshield 构建(通过 COM——如果有兴趣,请参阅此答案以获取基本信息),并且该过程的一部分涉及增加次要版本,以便在针对旧版本运行新安装程序时触发更新模式。

祝你好运!

于 2017-03-10T17:49:41.217 回答