Skip to content

EmbeddedResource is non-deterministic based on culture #9152

Open

Description

Describe the bug

The behavior of <EmbeddedResource> will change based on the culture settings of the current environment. By default it attempts to do culture specific resource handling. This is accomplished by taking the last portion of the file name, checking if it's a valid culture, if so then treat it like a culture specific resource. There is no way to override this behavior.

That means though if the final portion of your file name is a culture name on the current environment then it will be treated differently than other resources. Different OS / runtimes can have different cultures which altogether makes for non-deterministic behavior.

To Reproduce

  1. Create a simple console app
  2. Create a file called bin\System.Reflection.Metadata.dll.
  3. Include the following in your build file:
       <EmbeddedResource Include="bin\System.Reflection.Metadata.dll">
          <LogicalName>net.Metadata</LogicalName>
        </EmbeddedResource>
  1. Build

On Windows using dotnet build or msbuild this will produce a binary that has an embedded resource named net.Metadata. On Linux it will not because "metadata" is a valid culture name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions