Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenerateResource does not fail when converting binary .resx resources to .txt resources #308

Closed
cdmihai opened this issue Oct 21, 2015 · 2 comments · Fixed by #4830
Closed
Assignees
Labels
Area: Tasks Issues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll. bug .NET Core Task: GenerateResource Problems with the task itself, resgen.exe, and resx resources in general. triaged
Milestone

Comments

@cdmihai
Copy link
Contributor

cdmihai commented Oct 21, 2015

On the full framework, if a .resx data element points to a path and there's a type specified to read that file, the conversion of the .resx resource to a .txt resource is impossible and the tasks logs an error (since .txt resources cannot have binary values).

However, the .net core behaviour is to write the file path to the .txt.

This happens because the full framework uses a special xml reader, ResXResourceReader , that reads a path in the .resx file directly to its specified .net object. However this special xml reader is not available in .net core, so a normal xml reader is used instead, which just reads the text file name.

Tests that capture failure:

  • GenerateResource_Tests.UnsupportedTextType, InvalidReference, FailedResourceReader

Other implications

  • .resx binary resources with specified .net types don't work.

@dsplaisted Should we copy the ResXResourceReader type to the msbuild codebase? If we try to mimic its behaviour, we end up re-implementing it.

@cdmihai
Copy link
Contributor Author

cdmihai commented Oct 21, 2015

I looked at all the FEATURE_RESX_RESOURCE_READER instances, and it modified the contract in the following manner:

Read from .resx - allowed, but values are cast to string, not interpreted. Therefore binary resources referenced via a file are not loaded into their .net objects. Either the contract for resgen.exe and .resx format is different for .net core, or this is a bug
Read from .resource - not allowed

Write to .resx - not allowed
Write to .resource - yes, but by coercing values to string

rainersigwald added a commit to rainersigwald/msbuild that referenced this issue Sep 14, 2016
rainersigwald added a commit to rainersigwald/msbuild that referenced this issue Sep 14, 2016
@rainersigwald
Copy link
Member

This is fixable now that the ResX types are available in .NET Core 2, but MSBuild can't take advantage of that yet.

@rainersigwald rainersigwald added this to the MSBuild 16.0 milestone Dec 14, 2018
@rainersigwald rainersigwald added the Area: Tasks Issues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll. label Dec 14, 2018
rainersigwald added a commit to rainersigwald/msbuild that referenced this issue Jan 23, 2019
These now pass, or fail for a different reason.

Fixes dotnet#308.

fixup! Enable UnsupportedTextType test
@rainersigwald rainersigwald added the Task: GenerateResource Problems with the task itself, resgen.exe, and resx resources in general. label Mar 13, 2019
@livarcocc livarcocc modified the milestones: MSBuild 16.3, MSBuild 16.4 Aug 22, 2019
@rainersigwald rainersigwald self-assigned this Oct 7, 2019
rainersigwald added a commit to rainersigwald/msbuild that referenced this issue Oct 18, 2019
Closes dotnet#308 by re-enabling the tests.
rainersigwald added a commit that referenced this issue Oct 24, 2019
radical pushed a commit to radical/msbuild that referenced this issue Feb 14, 2020
…0213.12 (dotnet#308)

- Microsoft.Dotnet.Toolset.Internal - 3.1.200-preview.20113.12

Dependency coherency updates

- Microsoft.Net.Compilers - 3.5.0-beta3-20114-02 (parent: Microsoft.Dotnet.Toolset.Internal)
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Tasks Issues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll. bug .NET Core Task: GenerateResource Problems with the task itself, resgen.exe, and resx resources in general. triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants