.NET Core 中具有文化后缀的嵌入式资源

Embedded Resources with cultural suffix in .NET Core

我想在 ASP.NET Core 3 项目中将两个文件的 Build Action 设置为 Embedded resource

FileName.json
FileName.en-GB.json

但是当我尝试获取嵌入资源时,只有一个文件(第一个,没有文化后缀)

Namespace.Folder.FileName.json

起初,我猜想也许我必须直接在 .csproj 文件中添加第二个文件。

<ItemGroup>
  <EmbeddedResource Include="Folder\**\*.json" />
  <EmbeddedResource Include="Folder\FileName.en-GB.json" />
</ItemGroup>

但是它抛出一个错误:

Duplicate 'EmbeddedResource' items were included

表示已经添加

提前致谢

<ItemGroup>
     <!-- This line includes all .json files in Folder and it's subfolders-->
     <EmbeddedResource Include="Folder\**\*.json" />
     <!-- This line is not needed because all .json files are already included -->
     <EmbeddedResource Include="Folder\FileName.en-GB.json" />
</ItemGroup>

所以改成

<ItemGroup>
     <!-- This line includes all .json files in Folder and it's subfolders-->
     <EmbeddedResource Include="Folder\**\*.json" />
</ItemGroup>

请注意,FileName.en-GB.json 将包含在附属程序集中,而不是主输出程序集中。