2016-09-15 62 views
2

我的runsettings文件包含很少的连接字符串,我希望能够在VSTS中根据环境进行覆盖。在Visual Studio Team Services中覆盖包含分号的值的TestRun参数

我不想具体runsettings文件为每个环境,但我想用环境变量为了对我们其他部署版本的配置方式是一致的。

但是当我想转发到单元测试包含分号(;)的连接字符串(或任何参数)时,我遇到了问题。它正在被截断。我已经测试了传输其他值,但没有“;”成功。

environment variables

task configuration

settings.runsettings

 <?xml version="1.0" encoding="utf-8"?> 
     <RunSettings> 
      <TestRunParameters> 
      <Parameter name="CRM_CONNECTIONSTRING" value="Url = https://MYCRM.crm4.dynamics.com; [email protected]; Password=mypassword;" /> 
      <TestRunParameters>   
     </RunSettings> 

然而,exectuting(并显示在单元测试接收到的实际值)的值,在第一后截断时 “;”

enter image description here

是有保护价值的方法吗?

回答

1

在直接与Microsoft联系后,最终回答了我自己的解决方法。

问题上来,以及在这里正式VSTS任务github上:https://github.com/Microsoft/vsts-tasks/issues/2567

解决方法:试件任务之前,运行PowerShell脚本走的路径runsettings文件作为参数,读VSTS环境变量和direcly取代XML值在runsettings。

我提供了我的PowerShell脚本的位置:https://github.com/camous/vsts-powershell/blob/master/Set-RunSettings.ps1 (参数必须由前缀“__”)

,我写了一个更完整的“如何做”的位置:https://stuffandtacos.azurewebsites.net/2016/09/28/override-runsettings-parameters-in-visual-studio-team-service-when-value-contains-semi-colons/