vb.net app.config xml转换不起作用

时间:2015-10-12 09:57:28

标签: vb.net xslt app-config

我想在app.config中添加一些设置。通过预览,可以正确添加设置,但不能在构建后添加。

我的App.config

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <!--<providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>-->
  </entityFramework>
  <connectionStrings>
    <add name="BackOfficeEntities" connectionString="metadata=res://*/DAL.BackOfficeDAL.csdl|res://*/DAL.BackOfficeDAL.ssdl|res://*/DAL.BackOfficeDAL.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=MySource;initial catalog=***;persist security info=True;user id=***;password=***;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <appSettings />
</configuration>

我的App.Debug.config

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add key="inputDirectory" value="C:\Dev\Intranet_MISC\" xdt:Transform="Insert"  />
    <add key="outputDirectory" value="C:\Dev\Intranet_MISC\Traites\" xdt:Transform="Insert"  />
    <add key="historyDirectory" value="C:\Dev\Intranet_MISC\XmlHistory\" xdt:Transform="Insert"  />
    <add key="MH_ID_MOTIF_REPOS_HEBDO" value="16" xdt:Transform="Insert" />
  </appSettings>
</configuration>

构建后的最终app.config:

<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add key="inputDirectory" value="C:\Dev\Intranet_MISC\" xdt:Transform="Insert"  />
    <add key="outputDirectory" value="C:\Dev\Intranet_MISC\Traites\" xdt:Transform="Insert"  />
    <add key="historyDirectory" value="C:\Dev\Intranet_MISC\XmlHistory\" xdt:Transform="Insert"  />
    <add key="MH_ID_MOTIF_REPOS_HEBDO" value="16" xdt:Transform="Insert" />
    <add key="inputDirectory" value="C:\Dev\Intranet_MISC\"/>
    <add key="outputDirectory" value="C:\Dev\Intranet_Dekra_MISC\Traites\"/>
    <add key="historyDirectory" value="C:\Dev\Intranet_MISC\XmlHistory\"/>
    <add key="MH_ID_MOTIF_REPOS_HEBDO" value="16"/>
  </appSettings>
</configuration>

您对问题的根源有任何想法吗?

1 个答案:

答案 0 :(得分:0)

我找到了。在vbproj中我修改了一个属性:

自:

<PropertyGroup>
    <AppConfig>App.$(Configuration).config</AppConfig>
  </PropertyGroup>

要:

<PropertyGroup>
    <AppConfig>App.config</AppConfig>
  </PropertyGroup>

在ohters vbproj中,没有这个属性组。