ここでクイック&ダーティスクリプトをいじっています....
各ファイルに接続文字列要素が 1 つしかないことが確実な場合は、 と を組み合わせてこれを実現できxmlpeek
ますxmlpoke
。一部の C# を使用すると文字列の変更が簡単になるため、スクリプト タスクを使用して正規表現の検索と置換を行います。
<script language="C#" prefix="custom" >
<code>
<![CDATA[
[Function("fix")]
public static string Fix(string input) {
return Regex.Replace(input, @"localhost\\\w+", "localhost");
}
]]>
</code>
</script>
<!-- Get the existing connection string -->
<xmlpeek
file="config01/app.config"
xpath="/configuration/connectionStrings/add[@contains(@connectionString,'localhost\')]/@connectionString"
property="connectionstring">
</xmlpeek>
<!-- Write back the modified connection string -->
<xmlpoke
file="config01/app.config"
xpath="/configuration/connectionStrings/add[@contains(@connectionString,'localhost\')]/@connectionString"
value="${custom::fix(connectionstring)}">
</xmlpoke>