android: [regression/8.0.3] [Bug] .net8 Android not building because Resources from resx not found.
Description
While migrating from .net7 to .net8 i was facing the issue that my app is not compiling in vs code and vs4mac on my mac.
I get a lot of errors like:
error CS0234: The type or namespace name 'Resources' does not exist in the namespace 'StringResourcesBug' (are you missing an assembly reference?)
caused by code like this:
var x = StringResourcesBug.Resources.Strings.Resource.Test;
After a lot of trial an error, I found out the reason for this is the name of the class in the Resource.Designer.cs file. If you create a rest file with the name Resource.resx you are running into this issue. Renaming the file to Resources.resx and the Class to Resources fixes the issue
But the project was building on .net6 and .net7. Also iOs version in .net8 with Resouce.resx is building and is able to run. So I looks like a Android specific thing to me.
Steps to Reproduce
- Clone the Repo
- Open the Solution in VSCode or VS4Mac
- Compile the Solution while Targeting Android Emulator
Link to public reproduction project repository
https://github.com/Larhei/Maui-Issues/tree/main/StringResourcesBug
Version with bug
8.0.3
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
7.0.101
Affected platforms
Android
Affected platform versions
all android
Did you find any workaround?
Renaming the resx file and the name of the class in *.Designer.cs
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 35 (21 by maintainers)
Commits related to this issue
- .net8 Android not building because Resources from resx not found. Fixes https://github.com/dotnet/maui/issues/19117 With the release of the new Resource Designer assembly we purposely removed the ex... — committed to dellis1972/xamarin-android by dellis1972 2 years ago
- .net8 Android not building because Resources from resx not found. Fixes https://github.com/dotnet/maui/issues/19117 With the release of the new Resource Designer assembly we purposely removed the ex... — committed to dellis1972/xamarin-android by dellis1972 2 years ago
- .net8 Android not building because Resources from resx not found. Fixes https://github.com/dotnet/maui/issues/19117 With the release of the new Resource Designer assembly we purposely removed the ex... — committed to dellis1972/xamarin-android by dellis1972 2 years ago
- .net8 Android not building because Resources from resx not found. Fixes https://github.com/dotnet/maui/issues/19117 With the release of the new Resource Designer assembly we purposely removed the ex... — committed to dellis1972/xamarin-android by dellis1972 2 years ago
- .net8 Android not building because Resources from resx not found. Fixes https://github.com/dotnet/maui/issues/19117 With the release of the new Resource Designer assembly we purposely removed the ex... — committed to dellis1972/xamarin-android by dellis1972 2 years ago
- .net8 Android not building because Resources from resx not found. Fixes https://github.com/dotnet/maui/issues/19117 With the release of the new Resource Designer assembly we purposely removed the ex... — committed to dellis1972/xamarin-android by dellis1972 2 years ago
- [Xamarin.Android.Build.Tasks] Don't remove resx Resource.designer.cs (#9057) Fixes: https://github.com/dotnet/android/issues/9163 Context: dc3ccf28cdbe9f8c0a705400b83c11a85c81a980 Context: 3ec1b1... — committed to dotnet/android by dellis1972 2 years ago
Its because they have the same filename. We need to make the target a bit less agressive and ignore items which have the
DependentUpon. metadata I think.@last-Programmer not that I’m aware of. Its likely that VSForMac is not handling the new system, it might still be trying to make use of the old system. I’ll mention it to my collegue on the IDE team see if they can take a look.
I know. Its the inheritance, doh 🤦
@jonathanpeppers
Well I will try my best 😉