【问题标题】:vb.net app.config xml transform doesn't workvb.net app.config xml 转换不起作用
【发布时间】:2023-04-04 11:07:01
【问题描述】:

我想在我的 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>

你对问题的根源有什么想法吗?

【问题讨论】:

    标签: vb.net xslt app-config


    【解决方案1】:

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

    发件人:

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

    收件人:

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

    在其他 vbproj 中没有这个 propertyGroup。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-18
      • 2014-11-23
      • 2018-12-08
      • 2014-02-26
      • 1970-01-01
      • 2017-06-07
      • 1970-01-01
      相关资源
      最近更新 更多