如何通过TFS构建过程将参数传递给PowerShell脚本? [英] How to pass parameters to PowerShell script from TFS build process?

查看:115
本文介绍了如何通过TFS构建过程将参数传递给PowerShell脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个小PowerShell脚本来更改web.config中的连接字符串。

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?

(我使用基于脚本的新构建过程,因此参数只有一个内置的 Arguments字段)

(I use the new script based build process, so I only have a builtin "Arguments" field for the parameter)

推荐答案

您可以将所有参数放在一行中,放入Arguments文件中,如下所示:

You can put all parameters in a single line into Arguments files like this:

-webConfigPath "c:\web.config" -connectionStringName "My connection string"

这篇关于如何通过TFS构建过程将参数传递给PowerShell脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆