繁体   English   中英

NSIS - 变量没有正确解析

[英]NSIS - Variable is not resolving properly

我正在尝试使用compiler.nsh中的.define变量检查文件夹的版本,版本不匹配。 我正在尝试使用 ReplaceInFile 宏更新 compiler.nsh。 但是我在 ReplaceInFile 宏上提供的文件路径没有解析变量 ${CURRENT_KIT}? 我错过了什么吗? 请帮忙

;***************************************************************************************
; Version Check 
;***************************************************************************************
Var /GLOBAL CURRENT_KIT
Var /GLOBAL CURRENT_VER


;Function CompilerFile
Section 
    System::Call "kernel32::GetCurrentDirectory(i ${NSIS_MAX_STRLEN}, t .r0)"

    ${WordFind} "$0" "\" "-1" "$CURRENT_KIT"
    ${CharStrip} "${APP_CLASSKIT}"  "$CURRENT_KIT" "$CURRENT_VER"
    
    Push "$CURRENT_VER"
    Push "${CHK_VERSION}"
    Call VersionCheck
    Pop $0
    
    ${If} $0 == 0
    MessageBox MB_OK "Kit Version matches compiler.nsh"
    !define APP_VERSION "${CHK_VERSION}"
    ${ElseIf} $0 == 1
        !insertmacro _ReplaceInFile **"${NETWORK_PATH}\${CURRENT_KIT}\compiler.nsh"** '!define CHK_VERSION "${CHK_VERSION}"' '!define APP_VERSION "$CURRENT_VER"'

    ${EndIf}

我真的不知道您要做什么,但是如果我猜测该变量无法以这种方式解决。

而是尝试使用以下语法来解析字符串中的变量:

!insertmacro _ReplaceInFile **"${NETWORK_PATH}\$CURRENT_KIT\compiler.nsh"** '!define CHK_VERSION "${CHK_VERSION}"' '!define APP_VERSION "$CURRENT_VER"'

这些变量不需要额外的大括号。

如果我帮助您解决了您的问题,请告诉我。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM