Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TeamCity:更改NUnit测试运行程序的数据库配置_Teamcity - Fatal编程技术网

TeamCity:更改NUnit测试运行程序的数据库配置

TeamCity:更改NUnit测试运行程序的数据库配置,teamcity,Teamcity,在NUnit测试运行程序中对数据库运行测试时,我们的TeamCity CI实例无法使用与我们的开发人员机器相同的数据库配置 替换配置文件中的数据库连接字符串的最佳方法是什么?我查看了TeamCity的配置菜单,看不到任何明显的信息。据我所知,TeamCity中没有任何内置功能可以让您做到这一点,但您仍然可以通过多种方式实现所需的功能。一种是创建Powershell脚本,并使用Powershell runner作为TeamCity构建的一部分执行它 您的Powershell脚本可能如下所示: $c

在NUnit测试运行程序中对数据库运行测试时,我们的TeamCity CI实例无法使用与我们的开发人员机器相同的数据库配置


替换配置文件中的数据库连接字符串的最佳方法是什么?我查看了TeamCity的配置菜单,看不到任何明显的信息。

据我所知,TeamCity中没有任何内置功能可以让您做到这一点,但您仍然可以通过多种方式实现所需的功能。一种是创建Powershell脚本,并使用Powershell runner作为TeamCity构建的一部分执行它

您的Powershell脚本可能如下所示:

$config = 'C:\MyUnitTests.dll.config'
$doc = (Get-Content $config) -as [Xml]
$root = $doc.get_DocumentElement();
$newCon = $root.connectionStrings.add.connectionString.Replace('data source=SQL01','data source=SQL02');
$root.connectionStrings.add.connectionString = $newCon
$doc.Save($config)

借用自

的脚本据我所知,TeamCity中没有内置任何东西可以让您做到这一点,但是仍然有许多方法可以实现您想要的。一种是创建Powershell脚本,并使用Powershell runner作为TeamCity构建的一部分执行它

您的Powershell脚本可能如下所示:

$config = 'C:\MyUnitTests.dll.config'
$doc = (Get-Content $config) -as [Xml]
$root = $doc.get_DocumentElement();
$newCon = $root.connectionStrings.add.connectionString.Replace('data source=SQL01','data source=SQL02');
$root.connectionStrings.add.connectionString = $newCon
$doc.Save($config)
借来的剧本