替代为构建配置(MSBuild或NANT)反复调用XMLPoke?

时间:2017-01-25 19:27:18

标签: xml xslt msbuild nant xmlpoke

是否有一种有效的方法可以为.NET项目构建大型配置(需要设置许多属性)? XMLPoke适用于少量更改,但对于需要设置许多属性的大型更复杂项目,它不能很好地扩展。

以下是我当前配置文件之一的摘录:

[xmlpoke] Found '1' nodes matching XPath expression '/configuration/xyz.com/memcached/servers'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='ServiceName']/@value'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='DomainLoaderOptimization']/@value'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='MessageQueueProvider']/@value'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='DistributedCacheProvider']/@value'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='DistributedStateProvider']/@value'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='RedisHost']/@value'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='RedisHost.Batch']/@value'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='XYZService-ServiceUrlPrefix']/@value'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='PQRService-ServiceUrlPrefix']/@value'.
  [xmlpoke] Found '1' nodes matching XPath expression '/appSettings/add[@key='MNBOPUrlPrefix']/@value'.

我不想继续这么做几十次,反对多种服务的配置。

我已经研究过MSBuild转换,但这些似乎使得整个配置过程过于简洁。

1 个答案:

答案 0 :(得分:1)

SlowCheetah。 NuGet packageVisual Studio extension(可选)。