I created a little PowerShell script to change connection string in my web.config.
param([string]$webConfigPath, [string]$connectionStringName, [string]$connectionStringValue)
# get the full path of the web config file
$webConfigFile = [IO.Path]::Combine($webConfigPath, 'Web.config')
# load the XML
$webConfig = [xml](cat $webConfigFile)
#change the appropriate config
$webConfig.configuration.connectionStrings.add | foreach {
if($_.name -eq $connectionStringName){
$_.connectionString = $connectionStringValue
}
}
#save the file
$webConfig.Save($webConfigFile)
I added it to my build process. How to pass the build's variables to the script?
(I use the new script based build process, so I only have a builtin "Arguments" field for the parameter)