具有多个resx文件的RazorClassLibraries中的静态内容

时间:2019-02-07 14:09:08

标签: c# asp.net-core asp.net-core-2.2 razor-class-library

在我的Razor类库中,我需要包括js和css文件之类的静态文件。

我遵循了问题的解决方案 https://stackoverflow.com/a/53024912/8687825。我的项目设置有些不同。我有两个针对不同语言的resx文件。 项目的编译失败,并出现以下错误:

Error   MSB4018 The "GenerateEmbeddedResourcesManifest" task failed unexpectedly.
System.InvalidOperationException: An item with the name '' already exists.

这是csproj文件

<Project Sdk="Microsoft.NET.Sdk.Razor">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>   
    <NeutralLanguage>de</NeutralLanguage>
    <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.2.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Razor" Version="$(MicrosoftNETSdkRazorPackageVersion)" PrivateAssets="All" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
    <PackageReference Include="Telerik.UI.for.AspNet.Core" Version="2019.1.115" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Include="wwwroot\**\*" />
    <Content Update="**\*.cshtml" Pack="false" />
  </ItemGroup>

  <ItemGroup>
    <Compile Update="Properties\Resources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.en.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
    </EmbeddedResource>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
</Project>

为避免异常,我必须命名资源文件。但是如何命名?还是我的项目中配置错误?

0 个答案:

没有答案