Inno Setup'ta bir metin dosyasından uygulama sürümünü okuyun

Aug 18 2020

Bu satırı içeren bir TypeScript dosyam var:

export const version = '0.0.1';

Ve değeri erişmek isteyen versionve aktarın AppVersioniçinde Setupbölüm (ISS dosyası)

[Setup]
AppVersion={....}

Nasıl yapabilirim?

Yanıtlar

2 MartinPrikryl Aug 18 2020 at 19:51

Inno Setup'a benzer şekilde : Config.xml dosyasından AppVersion [Kurulum] değeri nasıl güncellenir? Bir normal ifade kullanarak sürümü dosyadan ayrıştırmak için önişlemciden PowerShell komut dosyasını kullanabilirsiniz:

#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")}