Inno Setup의 텍스트 파일에서 애플리케이션 버전 읽기
Aug 18 2020
이 줄이 포함 된 TypeScript 파일이 있습니다.
export const version = '0.0.1';
그리고이 값 액세스하려는 version
및로 가져올 AppVersion
에서 Setup
섹션 (ISS 파일)
[Setup]
AppVersion={....}
내가 어떻게 해?
답변
2 MartinPrikryl Aug 18 2020 at 19:51
Inno Setup : How to update AppVersion [Setup] value from Config.xml file 과 유사하게 전 처리기의 PowerShell 스크립트를 사용하여 정규식을 사용하여 파일에서 버전을 구문 분석 할 수 있습니다.
#define RetrieveVersion(str FileName) \
Local[0] = AddBackslash(GetEnv("TEMP")) + "version.txt", \
Local[1] = \
"-ExecutionPolicy Bypass -Command """ + \
"$contents = Get-Content '" + FileName + "';" + \ "$match = $contents | Select-String 'version\s*=\s*''(.*?)''';" + \ "$version = $match.Matches.Groups[1].Value;" + \ "Set-Content -Path '" + Local[0] + "' -Value $version;" + \
"""", \
Exec("powershell.exe", Local[1], SourcePath, , SW_HIDE), \
Local[2] = FileOpen(Local[0]), \
Local[3] = FileRead(Local[2]), \
FileClose(Local[2]), \
DeleteFileNow(Local[0]), \
Local[3]
[Setup]
AppVersion={#RetrieveVersion("C:\path\script.ts")}