代码之家  ›  专栏  ›  技术社区  ›  Jack0fshad0ws

dotnetcore CopyToOutputDirectory创建深度嵌套文件夹结构

  •  0
  • Jack0fshad0ws  · 技术社区  · 7 年前

    具有以下配置

    <Content Include="**/*.json">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
    

    创建深度嵌套的结构,例如。 bin>调试>netstandard2.0>[包含json文件的文件夹]然后再次返回bin>调试>netstandard2.0>[包含json文件的文件夹]bin>。。。

    即使项目只有平面结构 根

    *json文件

    所以预计只有 bin>调试>netstandard2.0>文件夹

    这是在macos上使用jetbrains rider,在使用

    谢谢

    1 回复  |  直到 7 年前
        1
  •  0
  •   Martin Ullrich    7 年前

    根据其web项目还是非web项目(使用SDK),您应该更新已设置必要排除项的现有项目:

    <None Update="**/*.json" CopyToOutputDirectory="PreserveNewest" />
    <!-- Web SDK sets some JSON files to Content -->
    <Content Update="**/*.json" CopyToOutputDirectory="PreserveNewest" />
    

    或者,如果要将某些文件添加到内容项,请使用如下排除:

    <Content Include="**\*.txt"
             CopyToOutputDirectory="PreserveNewest"
             Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" />
    <!-- ensure that project systems aren't confused when the same file is listed in different items -->
    <None Remove="**\*.txt" />