Question:
I created a little PowerShell script to change connection string in my web.config.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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)
Answer:
You can put all parameters in a single line into Arguments files like this:
1 2 |
-webConfigPath "c:\web.config" -connectionStringName "My connection string" |