Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Core 1.1 Resource File Issue

In my .NET Core class library project, the resource file does not get updated when the resource file name contains a dot in it. For example, when I add Resources.en.resx or Resources.es.resx files in the .NET Core project, the custom tool is not able to generate or update the C# resource file. Here is error message:

Custom tool ResXFileCodeGenerator failed to produce an output for input file 'Resources.en.resx' but did not log a specific error.

If you know any workaround or any fix for it, please kindly point me to the right direction

like image 960
Seth Kong Avatar asked May 05 '17 14:05

Seth Kong


4 Answers

Simply unload the project and reload it, the errors will disappear.

  1. Right click project in Solution Explorer > Unload Project
  2. Right click project in Solution Explorer > Reload Project
like image 164
CodingYoshi Avatar answered Oct 21 '22 16:10

CodingYoshi


Delete any .resx files currently in your Resources directory.

Now go to your Resources directory and right click for Add > New Item.

Choose Resource File and enter in a file name down the bottom of the form. It's important you get the name right first time and don't rename. You can use something like Resource.resx.

This very first Resource.resx file should have its own designer class. It also needs all the keys and values for localization for your project so if you have an existing Resource.en.resx you can copy and paste the values from that into this one.

If you need IStringLocalizer<Resource> or, in other words, you need to reference the Resource class somehow then you will need to go to Solution Explorer and left-click on the Resource.resx. In the Properties box there is a field called "Custom Tool". If you want a publically accessible class to be generated from the resx you will need to change this from ResXFileCodeGenerator to PublicResXFileCodeGenerator.

Now you can add the individual Resource.ja.resx, Resource.es.resx files. These do not need to have a custom tool ResXFileCodeGenerator run on them so you can remove that from the properties. This will fix your error message.

like image 13
David Rawson Avatar answered Oct 21 '22 17:10

David Rawson


I'm using VS2019 with .Net Standard 2.0 and still this error remain. I've try and try, ... deleting file, clean, rebuild. But still the error remain.

I've ended up to using ResXManager witch work fantastically well, it is available from the Visual Studio marketplace.

https://marketplace.visualstudio.com/items?itemName=TomEnglert.ResXManager

Thumb up for the ResXManager team!

like image 5
Hugo Avatar answered Oct 21 '22 17:10

Hugo


Based on the answer of @David Rawson I have been able to solve the error by doing the following:

  1. In the solution explorer Click on the Resource file that is mentioned in the error message
  2. Click F4 (for opening the Properties window)
  3. On Custom Tool on <reset to default>

That's it!

The error came up because I have changed the Access Modifier of the resource file from no code generation to public while I was testing some stuff.

like image 1
misanthrop Avatar answered Oct 21 '22 17:10

misanthrop