dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.98k stars 1.72k forks source link

[MAUI] `File.Designer.cs` is not generated for `File.resx` placed in MAUI Library #23716

Open wojciech-kulik opened 1 month ago

wojciech-kulik commented 1 month ago

Description

I migrated my shared Xamarin project to .NET MAUI Library. I need to use translations that are stored there. They need to be accessible from this library and from the MAUI app project that references this library.

However, when I copied Resources/File.resx to my MAUI Library, it doesn't auto-generate the corresponding Resources/File.Designer.cs file. I can create it manually, but I would like it to be auto-generated.

Steps to Reproduce

  1. Create MAUI Library (net8.0-android)
  2. Create MAUI App and reference MAUI Library.
  3. Add Resources/Strings.resx with sample translations to MAUI Library.
  4. Compile the app

Link to public reproduction project repository

No response

Version with bug

8.0.3 GA

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS

Affected platform versions

No response

Did you find any workaround?

No.

I tried adding it manually to csproj but it doesn't help:

  <ItemGroup>
    <Compile Update="Resources\Strings.Designer.cs"> 
      <DependentUpon>Strings.resx</DependentUpon>  
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen> 
    </Compile> 
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Update="Resources\Strings.resx"> 
      <Generator>ResXFileCodeGenerator</Generator> 
      <LastGenOutput>Strings.Designer.cs</LastGenOutput> 
    </EmbeddedResource>
  </ItemGroup>

Relevant log output

No response

github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Zhanglirong-Winnie commented 1 month ago

This issue has been verified using Visual Studio 17.11.0 Preview 4.0(8.0.61&8.0.3). Can repro on all platforms.