我想从此代码中提取版本号:
<?xml version="1.0" encoding="UTF-8"?>
<Include>
<?define ProductVersion = "1.0.0.0" ?>
</Include>
我希望输出为:1.0.0.0
,可以这样做吗?
最佳答案
如果您使用 Visual Studio 创建基于 WIX 的安装程序,则可以在 .wixproj
文件中定义 ProductVersion
变量。
<Target Name="BeforeBuild">
<PropertyGroup>
<DefineConstants>ProductVersion=1.0</DefineConstants>
...
</PropertyGroup>
</Target>
这可以通过 $(var.ProductVersion)
从 .wxs 文件访问。现在,您可以使用 XPath 从 .wixproj 文件中读取 DefineConstants
的值。这将为您提供 ProductVersion = "1.0.0.0"
关于xml - 是否可以使用 XPath 从处理指令 ('define' ) 中提取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17418750/