Web.Config转换不起作用

时间:2016-07-06 20:20:19

标签: asp.net visual-studio-2015 web.config-transform

使用VS 2k15,ASP.NET 4.5 我的变形不起作用。我正在预览,文件是相同的。然后我想,也许我必须部署才能看到转型。因此,我使用“部署配置”将自定义部署设置到我的桌面。发布后检查web.config,仍然与原始文件匹配。

知道我做错了吗?

我知道当我进行预览时,我会在预览的顶部收到一条警告:..."

These files have different encodings. Left file: Unicode (UTF-8) without signature. Right file: Unicode (UTF-8) with signature. You can resolve the difference by saving the right file with the encoding Unicode (UTF-8) without signature.

但是,当我选择保存选项并保存没有签名的部署文件(因此它们匹配)时,消息仍会出现。只是不确定发生了什么。我有什么想法可以改变这种转变吗?

的Web.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

  <appSettings>
      <add key="fileLibrary" value="c:\vsoProjects\localFiles\rlFileLibrary" />
  </appSettings>

  <connectionStrings>
      <add name="appConnString" connectionString="Data Source=(LocalDb);Initial Catalog=DevDB;User ID=*****;Password=*****;Connect Timeout=300" />
  </connectionStrings>

</configuration>

Web.ContDeploy.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <appSettings>
      <add key="fileLibrary" value="R:\rlFileLibrary" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
  </appSettings>

  <connectionStrings>
      <add name="appConnString" connectionString="Data Source=myserver.test.com;Initial Catalog=DeployDB;User ID=*****;Password=*****;Connect Timeout=300" xdt:Transform="SetAttributes(connectionString)" xdt:Locator="Match(name)"/>
  </connectionStrings>

  <system.web>
      <compilation xdt:Transform="RemoveAttributes(debug)" />    
  </system.web>

</configuration>

2 个答案:

答案 0 :(得分:1)

我发现了问题。这个项目从asp.net 2.x转换回4.5。

web.config在配置部分仍然有一个属性。

    Function ListTablesContainingField(SelectFieldName) As String

       Dim cn As New ADODB.Connection
       Dim rs As ADODB.Recordset
       Dim strTempList As String           

       Set cn = CurrentProject.Connection

      'Get names of all tables that have a column called <SelectFieldName>
       Set rs = cn.OpenSchema(adSchemaColumns, _
       Array(Empty, Empty, Empty, SelectFieldName))

      'List the tables that have been selected
       While Not rs.EOF
          'Exclude MS system tables
           If Left(rs!Table_Name, 4) <> "MSys" Then
               strTempList = strTempList & "," & rs!Table_Name
           End If
           rs.MoveNext
       Wend

       ListTablesContainingField = Mid(strTempList, 2)


       rs.Close
       Set cn = Nothing

   End Function

您可以在我发布的代码中看到它。我没有意识到它还在那里。毕竟那时我的头撞在我的桌子上,我只是删除了那个属性,预览变换,瞧它就在那里!也适当地部署。

答案 1 :(得分:0)

我不是变换方面的专家,但我对appSettings键的(工作)变换有这个签名:

  <appSettings>
    <add key="datafolder" value="D:\sites\removedpath\App_Data\" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
  </appSettings>

与你的略有不同