如何在 Nant 中将字符串评估为属性名称?
我正在重新调整我们的部署脚本,并已转移到每个定义的环境的外部配置文件。我将 ${environment} 和 ${system} 组件作为变量在命令行上传递。
我加载 config.${environment}.xml,其中包含一堆属性定义。
<property name="server.component1" value="server01" />
<property name="server.component2" value="server02" />
<property name="drive.component1" value="C:\" />
<property name="drive.component2" value="D:\" />
<property name="unc.component1" value="\\${server.component1}\Builds\${system}\${build.date}" />
<property name="unc.component2" value="\\${server.component2}\Builds\${system}\${build.date}" />
为了确定要部署到的服务器,我需要组合“server”和 ${system},然后将其计算为属性名称。我在这里缺少一些东西。
<property name="server" value="${'server.' + system}" /><!-- TODO make this work -->
<property name="server" value="server.${system}" />
I'm rejigging our deploy scripts, and have moved to external config files for each defined environment. I have the ${environment} and the ${system} component passed as variables on the command line.
I load config.${environment}.xml, which contains a bunch of property definitions.
<property name="server.component1" value="server01" />
<property name="server.component2" value="server02" />
<property name="drive.component1" value="C:\" />
<property name="drive.component2" value="D:\" />
<property name="unc.component1" value="\\${server.component1}\Builds\${system}\${build.date}" />
<property name="unc.component2" value="\\${server.component2}\Builds\${system}\${build.date}" />
To determine the server to deploy to, I need to combine 'server' and ${system} and then evaluate as a property name. I'm missing something here.
<property name="server" value="${'server.' + system}" /><!-- TODO make this work -->
<property name="server" value="server.${system}" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
property::get-value函数 应该有一些帮助:
The property::get-value function should be of some help: