Inno Setup:如何从Config.xml文件更新AppVersion[Setup]值
我想通过解析Inno Setup:如何从Config.xml文件更新AppVersion[Setup]值,xml,windows,inno-setup,Xml,Windows,Inno Setup,我想通过解析Versiontag,在编译时更新[Setup]节中的code>值 Config.xml文件具有以下配置: <?xml version="1.0" encoding="utf-8"?> <Configuration> <Version>1.0.1</Version> </Configuration> 1.0.1 我的应用程序正在使用应用程序版本的config.xml文件。我还想在Inno安装程序版本中使用相同的版
Version
tag,在编译时更新[Setup]
节中的code>值
Config.xml
文件具有以下配置:
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<Version>1.0.1</Version>
</Configuration>
1.0.1
我的应用程序正在使用应用程序版本的config.xml
文件。我还想在Inno安装程序版本中使用相同的版本
我是Inno安装脚本开发的新手。如果有人提供正确的方法,将非常有用。您可以使用简单的PowerShell代码,如:
$version=([xml](获取内容'config.xml')).Configuration.version
设置内容-路径“version.txt”-值$version
并使用以下命令运行它:
有关类似问题,请参见
尽管我假设应用程序编译器实际上使用config.xml
作为应用程序可执行版本。如果是这种情况,您可以更轻松地从.exe中检索版本
看
#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")}