netty
netty

Reputation: 111

Embedded resource in nuget package

I'm building a C# library to be packaged with NuGet. It contains some error code translations in a .resx file in the Resources directory called Errors.en.resx. The file has the "Build Action" set to "Embedded Resource" (which I've confirmed in the .csproj file), however when the project is built the resource ends up in a separate dll in a "en" folder.

This works fine as is, but when packaging with NuGet the "en" folder is missed, which means that attempts to use ResourceManager to fetch messages fail.

Ideally I'd like the resource embedded in the main .dll, but failing that I'll settle for adding the resource dll to the NuGet package. Various changes to settings and NuGet spec changes have not succeeded so far.

Upvotes: 5

Views: 12014

Answers (1)

netty
netty

Reputation: 111

In the end the simplest solution is to explicitly add the resource file in the NuGet Spec:

  <files>
    <file src="bin\$configuration$\en\*.dll" target="lib\net45\en" />
  </files>

Reference: Specifying Files to Include in the Package

Upvotes: 6

Related Questions