question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet build with ResXFileRef doesn't work

See original GitHub issue

See https://github.com/Microsoft/vsts-tasks/issues/5205

Build TaskRepro.zip using dotnet build and using msbuild.exe. You will notice the resources embedded in the output assembly are different:

Using dotnet build: image You’ll see it is just a string value.

Using msbuild.exe: image You’ll see it is actually a byte[].

This causes the resources.Designer.cs file’s code gen to error at runtime:

2017-09-01T20:07:41.9560273Z Initialization method Ommited.TestInitialize threw exception. System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]'..
2017-09-01T20:07:41.9600087Z Stack Trace:
2017-09-01T20:07:41.9649846Z at Ommited.ExtensionsResources.get_TestFile() in d:\a\1\s\src\Tests\Ommited\Resources\ExtensionsResources.Designer.cs:line 564
        /// <summary>
        ///   Looks up a localized resource of type System.Byte[].
        /// </summary>
        internal static byte[] TestFile {
            get {
                object obj = ResourceManager.GetObject("TestFile", resourceCulture);
                return ((byte[])(obj));
            }
        }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dasMullicommented, Sep 7, 2017

However this is kind of… 💩 So VS calls the netfx msbuild and it will happily embed a binary file. Then the file generator hooked up in VS uses netfx msbuild logic to generate the strongly typed code file (for which there isn’t a .net core implementation) and that works. When built on .NET Core, msbuild will only emit string resources and the previously generated code file crashes on decoding. Best thing is probably to emit a warning / error in msbuild when the resx entry has the type="…" attribute defined to indicate that this project should be built using the netfx msbuild or implement the embedding logic (by implementing the winforms embedding type via convention).

0reactions
nguerreracommented, Sep 12, 2017

This is a duplicate of https://github.com/Microsoft/msbuild/issues/2221

We generate satellite assemblies with our own code, but not the .resources files inside them. That is still handled by msbuild, and there is a bug in their handling on .NET Core.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Net resource with files content make docker build fail
What I found as solution is that you have to add file through the "Add Resource" -> "Add Existing File". After this I...
Read more >
dotnet build command - .NET CLI
The dotnet build command builds a project and all of its dependencies.
Read more >
NETSDK1045: The current .NET SDK does not support ...
Open the Solution Properties window (ctrl-click the solution in the Solution window and select Properties), select Build - General, and uncheck ...
Read more >
Managed Resources Editor writes relative file paths all in ...
Steps to reproduce: Create a new project (.Net core); Add a resource file (.resx); Add a binary file to the project (e.g. bitmap);...
Read more >
Problem with Resources.resx after updating DevExprtess
I've just worked out what the issue is, it occurs with the Projection Conversion program after upgrading the Control Suite, it does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found