Warm tip: This article is reproduced from serverfault.com, please click

.NET Core 1.1 Resource File Issue

发布于 2017-05-05 14:59:16

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

Questioner
Seth Kong
Viewed
0
David Rawson 2017-10-28 12:31:21

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.