I have written 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 have 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 show something like this in the dll.config
<add key="browser" value="%Config_Browser%" />
According to the TC documentation Config parameters require no prefix
"Configuration parameters (no prefix) are not passed into the build and are only meant to share settings within a build configuration. They are the primary means for customizing a build configuration which is based on a template or uses a meta-runner ."
For some reason my script only recognizes these parameters when I prefix them with another "%" for example
$xml.configuration.appSettings.add |Where-Object {$_.key -eq 'Browser'}|% {$_.value = '%%Config_Browser%'}
Would show something like this in the dll.config
<add key="browser" value="%%googlechrome%" />
Why is my script not recognizing my created parameters?
I would bet that the powershell piping is causing the issue because it is also using the % character. I would try replacing this alias with foreach instead and the build config parameter replacement should work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With