【问题标题】:app,config not overwritten or changes not picked up with custom app.config files according to Build cofiguration根据构建配置,应用程序、配置未覆盖或未使用自定义 app.config 文件获取更改
【发布时间】:2013-05-06 20:12:41
【问题描述】:

我目前正在使用 EntityFramework Code First 创建一个必须同时使用 localdb 和 sqlservercompact 4.0 的解决方案。我为此创建了额外的构建配置:LocalDb 和 SQLCE。显然,这些构建配置需要不同的 app.config 文件。 I found this excellent solution 并使用了第二个选项:使用 AfterBuild 指令更改 MSBuild 行为。所以我在 WPF 应用程序的项目文件中包含了以下 XML:

<Target Name="AfterBuild">
    <Delete Files="$(TargetDir)$(TargetFileName).config" />
    <Copy SourceFiles="$(ProjectDir)\Config\App.$(Configuration).config" DestinationFiles="$(TargetDir)$(TargetFileName).config" />
  </Target>

这在我在家的 Win8 开发笔记本电脑上运行良好,但在我工作的 Win7 桌面上似乎忽略了该指令。我注意到我的 class.dll 已注释掉模板以添加 PreBuild 和 AfterBuild 指令,而 WPF 应用程序没有它。我检查了构建屏幕以查看指令是否已执行。似乎更改不会再次被拾取或覆盖。发生了什么?

【问题讨论】:

    标签: visual-studio visual-studio-2012 msbuild app-config


    【解决方案1】:

    没关系:上面的解决方案适用于类库,例如单元测试项目。对于桌面应用程序,您确实需要Slow Cheetah。像魅力一样工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-13
      • 1970-01-01
      • 2011-11-03
      • 2019-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-20
      相关资源
      最近更新 更多