简体   繁体   中英

Resource in .Net Standard project is not added to DLL

A resource added to a .NET standard project does not get compiled into the DLL.

I'm porting a .NET Framework project to .NET Standard. My original project has some resources, marked as "Build Action : Resource" which are being consumed by other assemblies.

The .NET Standard project file.


  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup> *** not sure why this is added by VS2019 **
    <None Remove="Resources\ErrorLarge.png" />
  </ItemGroup>

  <ItemGroup>
    <Resource Include="Resources\ErrorLarge.png" />
  </ItemGroup>

</Project>

DLL content and size does not change with "Build Action" property changed from "None" to "Resource". Naturally my consumer assemblies will return a IOException: Cannot locate resource 'resources/errorlarge.png'. error.

VS2019 - 16.2.4

It sounds like you want EmbeddedResource in your CSProj file rather than Resource .

This seems useful at describing adding & reading them .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM