maui icon indicating copy to clipboard operation
maui copied to clipboard

The name 'Resources' is reserved and cannot be used.

Open EduardoReisDev opened this issue 2 years ago • 15 comments

Description

When adding fonts in the Resources/Fonts folder and adding them in MauiProgram, the following error was returned when compiling the project: "The name 'Resources' is reserved and cannot be used".

image image

Steps to Reproduce

  1. Add fonts in Resources/Fonts
  2. Adding them in MauiProgram
  3. Build project
  4. Error: "The name 'Resources' is reserved and cannot be used"

Link to public reproduction project repository

https://github.com/EduardoReisDev/SpaceXHistory

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 16

Did you find any workaround?

No response

Relevant log output

No response

EduardoReisDev avatar Oct 06 '22 23:10 EduardoReisDev

Same issue here! Changing build action also not working

suchithm avatar Oct 07 '22 12:10 suchithm

Could you try to clean up your csproj file? Visual Studio added a lot of tags that probably mess with this.

You should be able to remove this whole block: https://github.com/EduardoReisDev/SpaceXHistory/blob/main/SpaceXHistory/SpaceXHistory/SpaceXHistory.csproj#L51-L94

Additionally you probably want to add this line back: https://github.com/dotnet/maui/blob/main/src/Templates/src/templates/maui-mobile/MauiApp.1.csproj#L45

Does that help?

jfversluis avatar Oct 07 '22 14:10 jfversluis

Hi @EduardoReisDev. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Oct 07 '22 14:10 ghost

@jfversluis

  1. block removed.
  2. added line Commit: https://github.com/EduardoReisDev/SpaceXHistory/commit/32dd2b60d775725ed297546acfa0a910b3942ee2

New problem generated Crash: Screenshot at Oct 07 12-53-02

EduardoReisDev avatar Oct 07 '22 15:10 EduardoReisDev

Same issue here after copying an icon from one project to another.

julianadormon avatar Oct 08 '22 18:10 julianadormon

Cleaning the project does not help but restarting VS did for me.

julianadormon avatar Oct 08 '22 18:10 julianadormon

hi, I was getting the same error recently as well. in the csproj file you have the following line;

BundleResource Include="** \ *"

and after changing it to

BundleResource Include="Resources/*"

error was cleared and it run normally. hope it helps.

frz-ork avatar Oct 10 '22 20:10 frz-ork

@frz-ork, Thanks, I'll test it tonight and see if it works for me! Thank you once again!!

EduardoReisDev avatar Oct 11 '22 13:10 EduardoReisDev

This bug can also be reproduced by copying a file to the Images directory of a MAUI project. When I drag a file to the Images folder in Visual Studio for Mac (or copy via the Finder) we get auto-generated, but incorrect, additions to the .csproj file.

Adding the image file to the project: image

Incorrect addition to the .csproj file:

	<ItemGroup>
	  <None Remove="Resources\Images\main.png" />
	</ItemGroup>
	<ItemGroup>
	  <BundleResource Include="Resources\Images\main.png" />
	</ItemGroup>

Yielding this error: image

The fix is to remove the incorrect lines from the csproj file as shown above, and instead add this line:

		<MauiImage Include="Resources\Images\main.png" />

AloysA avatar Oct 16 '22 20:10 AloysA

Thanks, @AloysA , I'm getting that exact same error message, with VSM 17.4 build 2326.

The line that you mentioned, <MauiImage Include=...> where does it go? After all the other ItemGroups? Inside an ItemGroup? And do I leave the rest of the None's in the first ItemGroup alone (see below)?

And finally, as long as I'm besieging the group with questions here, what's the right way to add images to a project?

Thanks for any insights ... I'm getting tired of only being able to run on Android devices (I can run on macOS, but the icons look huge)

rogersm-uwosh avatar Oct 20 '22 14:10 rogersm-uwosh

Yes, add that line inside an item group. Or you can do all images at once as you can see in this example: https://github.com/dotnet/maui-samples/blob/main/6.0/Navigation/TabbedPage/TabbedPage/TabbedPage.csproj

AloysA avatar Oct 20 '22 15:10 AloysA

Get the same error only if want to deploy to an IOS local device. grafik In order to use a database i have an extra entry in the itemgroup which seems to be the problem. Dont know if i should open a seperate report, but its quite similar. Worked with the previous VS 2022 version. I did the upgrade because i didnt get the menu on the local device. Again the simulator works perfectly ...

whann0205 avatar Oct 24 '22 07:10 whann0205

Guys, i have a new problem: image

Look my .csproj file https://github.com/EduardoReisDev/SpaceXHistory/blob/main/SpaceXHistory/SpaceXHistory/SpaceXHistory.csproj

Can anyone help me?

EduardoReisDev avatar Oct 25 '22 22:10 EduardoReisDev

Latest Version of VS 2022, deleted obj and bin folder first, no matter what always resources reserved error. I dont have any BundledResource in my csproj file.

whann0205 avatar Oct 27 '22 08:10 whann0205

I dont have any NONE or Remove Entries: grafik

whann0205 avatar Oct 27 '22 10:10 whann0205

@EduardoReisDev and any folks still experiencing the Resources issue - could you please attach a binlog so that we can investigate further?

@EduardoReisDev as for the XamlParseException, could you please open a separate issue if you're still experiencing it?

Thanks :)

rachelkang avatar Nov 02 '22 19:11 rachelkang

Hi @EduardoReisDev. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Nov 02 '22 19:11 ghost

I dont have any NONE or Remove Entries: grafik

The issue occurs when you add into the .csproj something like: <MauiImage Update="Resources\Images\icon_tab_find_gray.png" BaseSize="30,30" />

vsimplea avatar Nov 03 '22 02:11 vsimplea

This is a duplicate of https://github.com/dotnet/maui/issues/10975

It is sometimes due to currupted csroj files or due to the fact you may be missing the LogicalName attribute on the MauiAsset.

If the issue of corrupted csproj persists then please open a new issue using the VS feedback as there may be a bug in the IDE.

mattleibow avatar Nov 03 '22 22:11 mattleibow

Thanks for the issue report @EduardoReisDev! This issue appears to be a problem with Visual Studio, so we ask that you use the VS feedback tool to report the issue. That way it will get to the routed to the team that owns this experience in VS.

If you encounter a problem with Visual Studio, we want to know about it so that we can diagnose and fix it. By using the Report a Problem tool, you can collect detailed information about the problem, and send it to Microsoft with just a few button clicks.

  1. Go to the Visual Studio for Windows feedback tool or Visual Studio for Mac feedback tool to report the issue
  2. Close this bug, and consider adding a link to the VS Feedback issue so that others can follow its activity there.

This issue will be automatically closed in 3 days if there are no further comments.

ghost avatar Nov 03 '22 22:11 ghost

I solved this problem by using "do remove Entry And Editor in 'Resources/Styles/style.xaml'".

:)

aespablo avatar Nov 09 '22 06:11 aespablo

@pablo-stelsi Thanks! Can you explain your solution in detail ? For example I do not have a Resources/Styles Directory...

whann0205 avatar Nov 09 '22 06:11 whann0205

@whann0205

This is my solution proccess

  1. Check App.xaml file (I found problem in Styles.xaml) image

  2. So editted this codes to looks like this. (check foreach styles.. ) image

  3. Finally,, I found Problem at this styles (Editor, Entry), and then remove this codes, and move to the local xaml styles ( for example: ContentsPage.Resources) image

  4. Good 👍

this is my solution

aespablo avatar Nov 09 '22 07:11 aespablo