我创建了一个小 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)
我将其添加到我的构建过程中。如何将构建的变量传递给脚本?
(我使用基于新脚本的构建过程,因此我只有一个内置的“参数”字段作为参数)
您可以将所有参数放在一行中放入 Arguments 文件中,如下所示:
-webConfigPath "c:\web.config" -connectionStringName "My connection string"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)