.NET MAUI – One or more invalid file names were detected.

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

  1. Open Finder.
  2. Navigate to the root directory of your project.
  3. Press Command + Shift + Period to toggle the visibility of hidden files.
  4. Look for any hidden files, particularly .DS_Store.
  5. 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

  1. Open File Explorer.
  2. Navigate to the root directory of your project.
  3. Select the “View” tab on the File Explorer ribbon.
  4. Check the “Hidden items” option in the “Show/hide” group.
  5. Look for any hidden files, and particularly check for files similar to .DS_Store (Windows might have different hidden files causing the issue).
  6. Delete or rename the problematic hidden files.
This content has 8 months. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.