In my build script, I have a powershell helper function, as shown below:
function set-connectionstring {
param($path, $name, $value)
$settings = [xml](get-content $path)
$setting = $settings.configuration.connectionStrings.add | where { $_.name -eq $name }
$setting.connectionString = "$value"
$setting.providerName = "System.Data.SqlClient"
$resolvedPath = resolve-path($path)
$settings.save($resolvedPath)
}
It works fine, except that when I try to set a value, it encodes ampersands strangely. Here is the problem:
My connection string has a value ". That should be perfectly fair. However, my code above converts this to ", which is completely unreasonable. Do you have an idea, can I solve this problem?
source
share