简体   繁体   English

NSIS - 变量没有正确解析

[英]NSIS - Variable is not resolving properly

I'm trying to check the version of folder with.define variable from compiler.nsh, On mismatch of version.我正在尝试使用compiler.nsh中的.define变量检查文件夹的版本,版本不匹配。 I'm trying to update compiler.nsh with ReplaceInFile macro.我正在尝试使用 ReplaceInFile 宏更新 compiler.nsh。 But the Filepath I have provided on the ReplaceInFile macro is not resolving variable ${CURRENT_KIT}?但是我在 ReplaceInFile 宏上提供的文件路径没有解析变量 ${CURRENT_KIT}? Am I missing something?我错过了什么吗? Please help请帮忙

;***************************************************************************************
; 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}

I don't really know what you are trying to do but if I am guessing the variable can not be resolved this way.我真的不知道您要做什么,但是如果我猜测该变量无法以这种方式解决。

Rather try this syntax for resolving the variables in a string:而是尝试使用以下语法来解析字符串中的变量:

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

You don't need the extra curly brackets for these kind of variables.这些变量不需要额外的大括号。

Let me know if I helped you with your issue.如果我帮助您解决了您的问题,请告诉我。

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

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