我需要在Windows环境中使用小工具来更改appsettings.config
中的条目。
它可以是一个cmd工具,我可以在其上写一个批处理文件。
有没有人有线索? 感谢
答案 0 :(得分:2)
使用xmlstarlet。 :) 谢谢npocmaka
更新
以下是我编写的使用xmlstarlet的代码段。
要更改文件:
../仓/配置/%〜1 / appSettings.config
<appSettings>
<add key="KillMobileService" value="0">
</appSetting>
到
<appSettings>
<add key="KillMobileService" value="1">
</appSetting>
使用
xml edit --pf --inplace --update "/appSettings/add[@key='KillMobileService']"/@value -v 1 ../bin/Config/%~1/appSettings.config
xml fo -t ../bin/Config/%~1/appSettings.config >../bin/Config/%~1/appSettings_new.config
del "..\bin\Config\%~1\appSettings.config"
ren "..\bin\Config\%~1\appSettings_new.config" "appSettings.config"
我使用edit和format命令。 检测到此内容更改时,IIS将重新启动。
编辑命令的doc链接:http://xmlstar.sourceforge.net/doc/UG/ch04s03.html
格式命令的doc链接:http://xmlstar.sourceforge.net/doc/UG/ch04s05.html
问题解决了。 = W =