我创建了一个小的PowerShell脚本来更改我的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)
我已将它添加到我的构建过程中。如何将构建变量传递到脚本中?
(我使用新的基于脚本的构建过程,因此只有一个内置的“参数”字段可用于参数)