我想通过parsingVersion
标签,在编译时从config.xml
文件更新[Setup]
部分的AppVersion
值。
Config.xml
文件具有以下configuration:
<?xml version="1.0" encoding="utf-8"?> <Configuration> <Version>1.0.1</Version> </Configuration>
我的应用程序使用应用程序版本的config.xml
文件。 我也想在Inno Setup安装程序版本中使用相同的版本。
我是Inno Setup脚本开发的新手。 如果有人提供我正确的做法,这将是非常有益的。
你可以使用一个简单的PowerShell代码:
$version = ([xml](Get-Content 'config.xml')).Configuration.Version Set-Content -Path 'version.txt' -Value $version
并使用Inno Setup预处理器运行它:
#define RetrieveVersion(str FileName) \ Local[0] = AddBackslash(GetEnv("TEMP")) + "version.txt", \ Local[1] = \ "-ExecutionPolicy Bypass -Command """ + \ "$version = ([xml](Get-Content '" + FileName + "')).Configuration.Version; " + \ "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\config.xml")}
尽管我假定应用程序编译器实际上使用config.xml
作为应用程序可执行版本。 如果是这种情况,则可以更容易地从.exe中检索版本。
请参阅如何根据我的应用程序版本自动设置我的Inno Setup安装程序的版本?