【问题标题】:Publishing external configuration files in ASP.Net MVC project using Visual Studio使用 Visual Studio 在 ASP.Net MVC 项目中发布外部配置文件
【发布时间】:2013-05-19 22:35:22
【问题描述】:

我有一个 ASP.net MVC 4 Web 应用程序,并且 web.config 正在引用一些其他外部配置文件(例如 )。 发布网站时,只会发布 web.config,并且不会部署这些外部文件。

注意:我已将这些外部配置文件的属性设置为: BuildAction : Content, Copy always too 但没有改变任何东西!

有人想出解决办法吗?

谢谢

【问题讨论】:

  • 你需要这样的东西吗? stackoverflow.com/questions/2747081/…
  • @matt 就是这样。投票结束作为欺骗。如果您想编写自己的正确答案版本,我会为您提供赏金,因为您首先获得了正确答案。

标签: asp.net visual-studio configuration transform publishing


【解决方案1】:

这样修改你的项目文件:

<PropertyGroup>
  <CopyAllFilesToSingleFolderForPackageDependsOn>
    CustomConfigFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForPackageDependsOn>

  <CopyAllFilesToSingleFolderForMsdeployDependsOn>
    CustomConfigFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>

<Target Name="CustomConfigFiles">
  <ItemGroup>
    <YourCustomConfigFiles Include="..\Path\To\Your\**\*.config" />

    <FilesForPackagingFromProject  Include="%(YourCustomConfigFiles)">
      <DestinationRelativePath>Target\Path\For\Your\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
    </FilesForPackagingFromProject>
  </ItemGroup>
</Target>

基于this答案

【讨论】:

  • 更像从这个答案复制 :/ 但至少找到了正确的答案。
猜你喜欢
  • 2020-11-23
  • 2013-02-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多