根据其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" />