2016-04-06 14 views
1

私はNSISプロではありませんが、私は手に入れました!私が構築している新しいソフトウェアのための新しいインストーラをセットアップしています。インストーラを2つの潜在的なパス、インストールまたはアップグレードで構成しました。NSISで選択されたオプションが奇妙な動作

ユーザがアップグレードオプションのいずれかを選択すると、インストールのために選択される可能性があるすべてのオプションが選択解除され、その逆も同様です。

現時点では、ユーザーがたとえばインストールパスの下で1つのオプションを選択し、そのパスのすべてのオプションが選択されていて、アップグレードパスの下でオプションを選択しないと選択解除できません興味深いことに、オプションの選択は、必要に応じて動作するように見えますか?

ここに私のコードがありますが、私はここで何が分かりませんか?

;-------------------------------- 
;Includes 
;-------------------------------- 

    !include "MUI2.nsh" 
    !include "nsDialogs.nsh" 
    !include "LogicLib.nsh" 
    !include "Sections.nsh" 
    !include "oledb.nsh" 
    !include "WinMessages.nsh" 
    !include "ReplaceInFile.nsh" 



;-------------------------------- 
;General 
;-------------------------------- 

    ;Name and file 
    Name "App" 
    OutFile "AppName ${Version}.exe" 

    ;Default installation folder 
    InstallDir "C:\appFolder" 

    ;Request application privileges for Windows Vista + 
    RequestExecutionLevel admin 

;-------------------------------- 
;Interface Settings 
;-------------------------------- 

    !define MUI_ABORTWARNING 
    Var Dialog 
    Var SQLServer 
    Var SQLUsername 
    Var SQLPassword 
    Var SDatabase 
    Var CoreDatabase 
    Var UIDatabase 

    ShowInstDetails "show" 

;-------------------------------- 
;Pages 
;-------------------------------- 

    !insertmacro MUI_PAGE_WELCOME 
    !insertmacro MUI_PAGE_LICENSE "LIC.rtf" 
    !insertmacro MUI_PAGE_COMPONENTS 
    Page Custom SQLConnectionDetails SQLConnectionDetailsPageLeave 
    Page Custom DatabaseDetails DatabaseDetailsLeave 
    !insertmacro MUI_PAGE_DIRECTORY 
    !insertmacro MUI_PAGE_INSTFILES 
    !insertmacro MUI_PAGE_FINISH 

;-------------------------------- 
;onInit 
;-------------------------------- 

Function .onInit 
    InitPluginsDir 
    StrCpy $1 "SecMain" 

FunctionEnd 

;-------------------------------- 
;Page functions 
;-------------------------------- 

Function SQLConnectionDetails 
    !insertmacro MUI_HEADER_TEXT $(SQLServerDetailsTitle) $(SQLServerDetailsSubTitle) 
    nsDialogs::Create 1018 
    pop $Dialog 
    ${If} $Dialog == error 
     Abort 
    ${EndIf} 

    ;x, y, width, height and text 
    ${NSD_CreateLabel} 0 0 100% 10u "Enter the name of the SQL server that AppName is to be installed on" 
    pop $1 
    ${NSD_CreateText} 0 10u 150u 12u "" 
    pop $SQLServer 

    ${NSD_CreateLabel} 0 25u 100% 10u "Enter the database name" 
    pop $2 
    ${NSD_CreateText} 0 35u 100u 12u "" 
    pop $SDatabase 

    ${NSD_CreateLabel} 0 50u 100% 10u "Enter SQL username" 
    pop $3 
    ${NSD_CreateText}} 0 60u 100u 12u "" 
    pop $SQLUsername 

    ${NSD_CreateLabel} 0 75u 100% 10u "Enter SQL password" 
    pop $4 
    ${NSD_CreatePassword} 0 85u 100u 12u "" 
    pop $SQLPassword 

    nsDialogs::Show 
FunctionEnd 

Function SQLConnectionDetailsPageLeave 
    ${NSD_GetText} $SQLServer $SQLServer 
    ${NSD_GetText} $SQLUsername $SQLUsername 
    ${NSD_GetText} $SQLPassword $SQLPassword 
    ${NSD_GetText} $SDatabase $SDatabase 
    messagebox MB_OK "We will now attempt to connect to the database server." 
    MSSQL_OLEDB::SQL_Logon "$SQLServer" "$SQLUsername" "$SQLPassword" 
    pop $0 

    ${If} $0 = 0 
     ;messagebox MB_OK "Connection sucessful" 
    ${Else} 
     messagebox MB_OK "I encountered an issue whilst trying to connect to the database. Please check your details and try again." 
     abort 
    ${EndIf} 

    MSSQL_OLEDB::SQL_Logout 
FunctionEnd 

Function DatabaseDetails 
    !insertmacro MUI_HEADER_TEXT $(DatabaseNamesTitle) $(DatabaseNamesSubTitle) 
    nsDialogs::Create 1018 
    pop $Dialog 
    ${If} $Dialog == error 
     Abort 
    ${EndIf} 

    ;x, y, width, height and text 
    ${NSD_CreateLabel} 0 0 100% 10u "Enter the name to be given to the Core database" 
    pop $1 
    ${NSD_CreateText} 0 10u 150u 12u "" 
    pop $CoreDatabase 

    ${NSD_CreateLabel} 0 25u 100% 10u "Enter the name to be given to the UI database" 
    pop $2 
    ${NSD_CreateText} 0 35u 100u 12u "" 
    pop $UIDatabase 

    nsDialogs::Show 
FunctionEnd 

Function DatabaseDetailsLeave 
${NSD_GetText} $CoreDatabase $CoreDatabase 
${NSD_GetText} $UIDatabase $UIDatabase 
FunctionEnd 

;-------------------------------- 
;Languages 
;-------------------------------- 

    !insertmacro MUI_LANGUAGE "English" 

;-------------------------------- 
;Installer Sections 
;-------------------------------- 
InstType "New Install" 
InstType "New Install - Full" 
InstType "Upgrade" 

;------------ 
;New Install 
;------------ 

SectionGroup /e "!Install" SecGroupNewInstall 
    Section "Main App" SecMain 

    SectionEnd 

    Section /o "App1" SecApp1 

    SectionEnd 

    Section /o "App2" SecApp2 

    SectionEnd 

    Section /o "App3" SecApp3 

    SectionEnd 

    Section /o "App4" SecApp4 

    SectionEnd 

    SectionGroup /e "Optional" SubSecGroupNewInstall 
     Section /o "App5" SecApp5 

     SectionEnd 

     Section /o "App6" SecApp6 

     SectionEnd 

     Section /o "App7" SecApp7 

     SectionEnd 
    SectionGroupEnd 
SectionGroupEnd 

SectionGroup /e "!Upgrade" SecGroupUpgrade 
    Section /o "Upgrade Main App" SecMainUpgrade   
    SectionEnd 
SectionGroupEnd 

;-------------------------------- 
;onSelChange 
;-------------------------------- 

Function .onSelChange 

    !insertmacro StartRadioButtons $1 
     !insertmacro RadioButton ${SecMain} 
     !insertmacro RadioButton ${SecMainUpgrade} 
    !insertmacro EndRadioButtons 

    !insertmacro SectionFlagIsSet ${SecMain} ${SF_SELECTED} InstisSel InstnotSel 
     InstnotSel: 
      !insertmacro UnselectSection ${SecGroupNewInstall} 
     InstisSel: 

    !insertmacro SectionFlagIsSet ${SecMainUpgrade} ${SF_SELECTED} UpgisSel UpgnotSel 
     UpgnotSel: 
    !insertmacro UnselectSection ${SecGroupUpgrade} 
     UpgisSel: 

FunctionEnd 

答えて

1

私は自分の質問に答えました! 問題は、タイミングと、私のonInit関数の問題の両方にまで及んでいませんでした。私はセクショングループの下に私のonInit関数を移動し、StrCpyが正しいセクション参照を含むように修正しました。以下の訂正コードを参照してください。

;-------------------------------- 
;Includes 
;-------------------------------- 

    !include "MUI2.nsh" 
    !include "nsDialogs.nsh" 
    !include "LogicLib.nsh" 
    !include "Sections.nsh" 
    !include "oledb.nsh" 
    !include "WinMessages.nsh" 
    !include "ReplaceInFile.nsh" 



;-------------------------------- 
;General 
;-------------------------------- 

    ;Name and file 
    Name "App" 
    OutFile "AppName ${Version}.exe" 

    ;Default installation folder 
    InstallDir "C:\appFolder" 

    ;Request application privileges for Windows Vista + 
    RequestExecutionLevel admin 

;-------------------------------- 
;Interface Settings 
;-------------------------------- 

    !define MUI_ABORTWARNING 
    Var Dialog 
    Var SQLServer 
    Var SQLUsername 
    Var SQLPassword 
    Var SDatabase 
    Var CoreDatabase 
    Var UIDatabase 

    ShowInstDetails "show" 

;-------------------------------- 
;Pages 
;-------------------------------- 

    !insertmacro MUI_PAGE_WELCOME 
    !insertmacro MUI_PAGE_LICENSE "LIC.rtf" 
    !insertmacro MUI_PAGE_COMPONENTS 
    Page Custom SQLConnectionDetails SQLConnectionDetailsPageLeave 
    Page Custom DatabaseDetails DatabaseDetailsLeave 
    !insertmacro MUI_PAGE_DIRECTORY 
    !insertmacro MUI_PAGE_INSTFILES 
    !insertmacro MUI_PAGE_FINISH 

;-------------------------------- 
;Page functions 
;-------------------------------- 

Function SQLConnectionDetails 
    !insertmacro MUI_HEADER_TEXT $(SQLServerDetailsTitle) $(SQLServerDetailsSubTitle) 
    nsDialogs::Create 1018 
    pop $Dialog 
    ${If} $Dialog == error 
     Abort 
    ${EndIf} 

    ;x, y, width, height and text 
    ${NSD_CreateLabel} 0 0 100% 10u "Enter the name of the SQL server that AppName is to be installed on" 
    pop $1 
    ${NSD_CreateText} 0 10u 150u 12u "" 
    pop $SQLServer 

    ${NSD_CreateLabel} 0 25u 100% 10u "Enter the database name" 
    pop $2 
    ${NSD_CreateText} 0 35u 100u 12u "" 
    pop $SDatabase 

    ${NSD_CreateLabel} 0 50u 100% 10u "Enter SQL username" 
    pop $3 
    ${NSD_CreateText}} 0 60u 100u 12u "" 
    pop $SQLUsername 

    ${NSD_CreateLabel} 0 75u 100% 10u "Enter SQL password" 
    pop $4 
    ${NSD_CreatePassword} 0 85u 100u 12u "" 
    pop $SQLPassword 

    nsDialogs::Show 
FunctionEnd 

Function SQLConnectionDetailsPageLeave 
    ${NSD_GetText} $SQLServer $SQLServer 
    ${NSD_GetText} $SQLUsername $SQLUsername 
    ${NSD_GetText} $SQLPassword $SQLPassword 
    ${NSD_GetText} $SDatabase $SDatabase 
    messagebox MB_OK "We will now attempt to connect to the database server." 
    MSSQL_OLEDB::SQL_Logon "$SQLServer" "$SQLUsername" "$SQLPassword" 
    pop $0 

    ${If} $0 = 0 
     ;messagebox MB_OK "Connection sucessful" 
    ${Else} 
     messagebox MB_OK "I encountered an issue whilst trying to connect to the database. Please check your details and try again." 
     abort 
    ${EndIf} 

    MSSQL_OLEDB::SQL_Logout 
FunctionEnd 

Function DatabaseDetails 
    !insertmacro MUI_HEADER_TEXT $(DatabaseNamesTitle) $(DatabaseNamesSubTitle) 
    nsDialogs::Create 1018 
    pop $Dialog 
    ${If} $Dialog == error 
     Abort 
    ${EndIf} 

    ;x, y, width, height and text 
    ${NSD_CreateLabel} 0 0 100% 10u "Enter the name to be given to the Core database" 
    pop $1 
    ${NSD_CreateText} 0 10u 150u 12u "" 
    pop $CoreDatabase 

    ${NSD_CreateLabel} 0 25u 100% 10u "Enter the name to be given to the UI database" 
    pop $2 
    ${NSD_CreateText} 0 35u 100u 12u "" 
    pop $UIDatabase 

    nsDialogs::Show 
FunctionEnd 

Function DatabaseDetailsLeave 
${NSD_GetText} $CoreDatabase $CoreDatabase 
${NSD_GetText} $UIDatabase $UIDatabase 
FunctionEnd 

;-------------------------------- 
;Languages 
;-------------------------------- 

    !insertmacro MUI_LANGUAGE "English" 

;-------------------------------- 
;Installer Sections 
;-------------------------------- 
InstType "New Install" 
InstType "New Install - Full" 
InstType "Upgrade" 

;------------ 
;New Install 
;------------ 

SectionGroup /e "!Install" SecGroupNewInstall 
    Section "Main App" SecMain 

    SectionEnd 

    Section /o "App1" SecApp1 

    SectionEnd 

    Section /o "App2" SecApp2 

    SectionEnd 

    Section /o "App3" SecApp3 

    SectionEnd 

    Section /o "App4" SecApp4 

    SectionEnd 

    SectionGroup /e "Optional" SubSecGroupNewInstall 
     Section /o "App5" SecApp5 

     SectionEnd 

     Section /o "App6" SecApp6 

     SectionEnd 

     Section /o "App7" SecApp7 

     SectionEnd 
    SectionGroupEnd 
SectionGroupEnd 

SectionGroup /e "!Upgrade" SecGroupUpgrade 
    Section /o "Upgrade Main App" SecMainUpgrade   
    SectionEnd 
SectionGroupEnd 

;-------------------------------- 
;onInit 
;-------------------------------- 

Function .onInit 
    InitPluginsDir 
    StrCpy $1 ${SecMain} 

FunctionEnd 

;-------------------------------- 
;onSelChange 
;-------------------------------- 

Function .onSelChange 

    !insertmacro StartRadioButtons $1 
     !insertmacro RadioButton ${SecMain} 
     !insertmacro RadioButton ${SecMainUpgrade} 
    !insertmacro EndRadioButtons 

    !insertmacro SectionFlagIsSet ${SecMain} ${SF_SELECTED} InstisSel InstnotSel 
     InstnotSel: 
      !insertmacro UnselectSection ${SecGroupNewInstall} 
     InstisSel: 

    !insertmacro SectionFlagIsSet ${SecMainUpgrade} ${SF_SELECTED} UpgisSel UpgnotSel 
     UpgnotSel: 
    !insertmacro UnselectSection ${SecGroupUpgrade} 
     UpgisSel: 

FunctionEnd 
関連する問題