Developers working on .NET MAUI projects may encounter a perplexing error during the build process, revealing invalid file names that must adhere to specific rules.
/usr/local/share/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.101/targets/Microsoft.Maui.Resizetizer.targets(525,9): error : One or more invalid file names were detected. File names must be lowercase, start and end with a letter character, and contain only alphanumeric characters orunderscores.
The Solution
To resolve this issue, developers need to identify and correct the problematic file names. On macOS, the hidden file .DS_Store
is a common culprit causing this error. Here’s a step-by-step guide to resolving the issue:
For macOS
- Open Finder.
- Navigate to the root directory of your project.
- Press
Command + Shift + Period
to toggle the visibility of hidden files. - Look for any hidden files, particularly
.DS_Store
. - Delete or rename the problematic hidden files.
If the Finder app does not show any files, try opening a terminal, navigate to the resources folder of your project, and type ls -la
to see the files. It should display the invalid files. Remove them accordingly.
For Windows
- Open File Explorer.
- Navigate to the root directory of your project.
- Select the “View” tab on the File Explorer ribbon.
- Check the “Hidden items” option in the “Show/hide” group.
- Look for any hidden files, and particularly check for files similar to
.DS_Store
(Windows might have different hidden files causing the issue). - Delete or rename the problematic hidden files.