TeamCity does not recognize configuration options

I wrote this script

$xml = New-Object XML
$xml.Load(".\build\DashboardUITests.dll.config")
$xml.configuration.appSettings.add |Where-Object {$_.key -eq 'Browser'}|% {$_.value = '%Config_Browser%'}
$xml.configuration.appSettings.add |Where-Object {$_.key -eq 'Environment'}|% {$_.value = '%Config_Enviroment%'}
$xml.configuration.appSettings.add |Where-Object {$_.key -eq 'baseUrl'}|% {$_.value = '%Config_URL%'}
$xml.Save(".\build\DashboardUITests.dll.config")

      

And created these three build parameters in the build config I am using.

Config_Browser = googlechrome
Config_Enviroment = MyEnviroment
Config_URL = BigUrl

      

At the moment the script will display something like this in the dll.config

<add key="browser" value="%Config_Browser%" />

      

According to the vehicle documentation, configuration parameters do not require a prefix

"Configuration parameters (no prefix) are not passed to the assembly and are only intended to share settings in the assembly configuration. They are the primary means of customizing assembly configuration that is template-based or uses a meta-runner."

For some reason, my script only recognizes these parameters when I prefix them with another "%" like

$xml.configuration.appSettings.add |Where-Object {$_.key -eq 'Browser'}|% {$_.value = '%%Config_Browser%'}

      

Will output something like this in dll.config

<add key="browser" value="%%googlechrome%" />

      

Why doesn't my script recognize my generated parameters?

+3


source to share


1 answer


I would bet the PowerShell issue is causing the problem because it also uses the% character. I would try to replace this alias foreach

, and replacing the build config parameter should work as expected.



+1


source







All Articles