Compile error with WPF .net Core 3.0 when adding .resx files
Asked Answered
R

2

5

Following works as expected: VS Studio 2019 tested with professional and community.

  • Create new APF App (.NET Framework)
  • Open properties Folder
  • Change Resources.resx to public
  • Create a new resources file (Resources.de.resx)
  • Build

Compiles as expected

Following does not work:

  • Create new APF App (.NET Core)
  • Create a Resources Folder
  • Create a new resources file (Resources.resx)
  • Change it to public
  • Create a new resources file (Resources.de.resx)
  • Build

Tested it on 3 different machines with VS 2019 professional and community

Compile Errors:

Error Custom tool PublicResXFileCodeGenerator failed to produce an output for input file 'Resources\Resources.de.resx' but did not log a specific error. WpfApp4 C:...\source\repos\WpfApp4\WpfApp4\Resources\Resources.de.resx 1

Error MSB3086 Task could not find "al.exe" using the SdkToolsPath "" or the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.7.2\WinSDK-NetFx40Tools-x86". Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed WpfApp4 C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 3639

EDIT: Also created a Ticket at Microsoft

https://developercommunity.visualstudio.com/content/problem/771961/compile-error-with-wpf-net-core-30-when-adding-res.html

Roping answered 9/10, 2019 at 6:40 Comment(3)
Personally, I use resource dictionaries for localisation and recommend that approach. Not used a resx file in wpf for quite some time. If you add the microsoft.windows.compatibility nuget package does it work? If no then. Take a look at the steps in here learn.microsoft.com/en-us/dotnet/desktop-wpf/migration/…Notum
I'm not fixated on any particular localization method. If there is a better way I will take that. resx files only seemed to be the Standard to me. I am also Looking at Mozillas Fluent but there is hardly to find documentation and examples.Roping
The approach I've used several times has a base rd with English. A string per entry with an x:key. Merge in a language resource dictionary with matching keys. Use dynamicresource for textblocks etc referencing those keys. Often the non-English is a subset because the super users are all English readers so their maintenance screens can use English for labelling. This approach also fits with branding.Notum
T
4

Try to install .NET Framework 4.7.2 Developer Pack. It is needed only for compilation.

Twinkling answered 22/10, 2019 at 12:55 Comment(0)
N
2

In VisualStudio 2019 in an asp.net core 3.1 webSite project (using Globalization), I faced this issue when I used an existing resource file.

To solve the issue:

  1. Created a new Resource.resx. (Using Add>New Item...>Resorce File.resx .
  2. Copy all contents of the first file in the new file (Copy all three columns).
  3. Delete the old file.
  4. Rename the new file to the intended name.

It worked for me. I wish it works for you too.

Nephron answered 3/9, 2020 at 21:7 Comment(1)
And don't forget to change access modifier of resx file to "public"Cortes

© 2022 - 2024 — McMap. All rights reserved.