Dot-Net
如何在使用 Nant 建構時自動更改連接字元串
當建構類型是使用 Nant 發佈時,是否可以自動更改我的 web.config 中的連接字元串?如果是這樣,如何?謝謝
我認為您可以使用 xmlpoke 任務。例如,如果您的 web.config 是
<?xml version="1.0"?> <configuration> <connectionStrings> <add name="myDb" connectionString="blah" providerName="blah"/> </connectionStrings> </configuration>然後你可以像這樣向你的建構文件添加一個任務。
<xmlpoke file="path_to_your_web_root\Web.config" xpath="/configuration/connectionStrings/add[@name='myDb']/@connectionString" value="your_connection_string" />哦,這裡是 xmlpoke 任務的文件。http://nant.sourceforge.net/release/latest/help/tasks/xmlpoke.html