簡體   English   中英

如何從TFS構建過程將參數傳遞給PowerShell腳本?

[英]How to pass parameters to PowerShell script from TFS build process?

我創建了一個小的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”字段用於參數)

您可以將所有參數放在一行中的Arguments文件中,如下所示:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM