Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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
C# App.Config转换不工作_C#_Xml_Tfs_Tfsbuild - Fatal编程技术网

C# App.Config转换不工作

C# App.Config转换不工作,c#,xml,tfs,tfsbuild,C#,Xml,Tfs,Tfsbuild,我试图在我的构建服务器上手动更改app.config,我创建了一个名为build的配置,我有以下4.config文件 这是我的app.config <connectionStrings> <!--configSource="connectionStrings.config"--> <add name="TestContext" connectionString="Data Source=ServerDoesNotExist;Initial Catal

我试图在我的构建服务器上手动更改app.config,我创建了一个名为build的配置,我有以下4.config文件

这是我的app.config

<connectionStrings>
    <!--configSource="connectionStrings.config"-->
    <add name="TestContext" connectionString="Data Source=ServerDoesNotExist;Initial Catalog=TestDb; Integrated Security=true" providerName="System.Data.SqlClient" />
</connectionStrings>

在我的app.build.config上

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionstrings xdt:transform="Replace">
      <add name="TestContext" connectionstring="Data Source=REALEXISTINGSERVER;Initial Catalog=TestDb; Integrated Security=true" providername="System.Data.SqlClient"/>
  </connectionstrings>
</configuration>

然而,当我创建构建定义并添加
configuration=build
时,我得到了这个错误

错误:System.Data.SqlClient.SqlException:建立到SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:命名管道提供程序,错误:40-无法打开到SQL Server的连接)--->System.ComponentModel.Win32异常:未找到网络路径


这意味着使用app.config文件而不是转换

您可以使用SetAttributes

<connectionStrings>
    <add name="TestContext" connectionString="Data Source=REALEXISTINGSERVER;Initial Catalog=TestDb; Integrated Security=true" providername="System.Data.SqlClient" 
    xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
  </connectionStrings>


您可以使用SetAttributes

<connectionStrings>
    <add name="TestContext" connectionString="Data Source=REALEXISTINGSERVER;Initial Catalog=TestDb; Integrated Security=true" providername="System.Data.SqlClient" 
    xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
  </connectionStrings>


您是否已检查文件是否在本地macine(即从Visual Studio)上正确转换。转换文件上的生成操作可能是错误的。您是否检查了该文件是否在本地macine(即Visual Studio)上正确转换。转换文件上的生成操作可能是错误的