question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error APT0003 Invalid file name: It must contain only [^a-zA-Z0-9_.]+ for file OpenSans-Regular.ttf

See original GitHub issue

Description

I have installed the last version of Visual Studio 2022 preview, 17.1.0 Preview 1.1, and I just created a MAUI project with the template of visual studio and then I try to compile it. I get the following error:

Error APT0003 Invalid file name: It must contain only [^a-zA-Z0-9_.]+ for file OpenSans-Regular.ttf

The project is in a folder which path has not blank spaces, neither another not allowed caracters. This is the complete path of the folder:

C:\proyectos\GestorOrdenadores\GestorOrdenadores.Cliente.XamarinMaui\Resources\Fonts

Thanks.

Steps to Reproduce

1.- Create a MAUI project witth Visual Studio 2022 template 2.- Compile MAUI project

Version with bug

Preview 11

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Andriod

Did you find any workaround?

No response

Relevant log output

Operación Recompilar iniciada...
Se ha restaurado C:\proyectos\GestorOrdenadores\GestorOrdenadores.Service.Grpc.DotNet\GestorOrdenadores.Service.Grpc.DotNet.csproj (en 4,09 sec).
Se ha restaurado C:\proyectos\GestorOrdenadores\GestorOrdenadores.Cliente.Wpf\GestorOrdenadores.Cliente.Wpf.csproj (en 4,1 sec).
Se ha restaurado C:\proyectos\GestorOrdenadores\GestorOrdenadores.Cliente\GestorOrdenadores.Cliente.csproj (en 4,09 sec).
Se ha restaurado C:\proyectos\GestorOrdenadores\GestorOrdenadores.Service.Comun\GestorOrdenadores.Service.Comun.csproj (en 4,12 sec).
1>------ Operación Recompilar todo iniciada: proyecto: GestorOrdenadores.Cliente.XamarinMaui, configuración: Debug Any CPU ------
Se ha restaurado C:\proyectos\GestorOrdenadores\GestorOrdenadores.Cliente.XamarinMaui\GestorOrdenadores.Cliente.XamarinMaui.csproj (en 4,77 sec).
1>Resources\Fonts\OpenSans-Regular.ttf : error APT0003: Invalid file name: It must contain only [^a-zA-Z0-9_.]+.
1>Compilación del proyecto "GestorOrdenadores.Cliente.XamarinMaui.csproj" terminada -- ERROR.
========== Recompilar todo: 0 correctos, 1 incorrectos, 0 omitidos ==========

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nextfoolcommented, Jan 25, 2022

@MagicAndre1981 I have exactly the same issue with vs 2022 17.1 preview3. If I remove the ‘-’ from the file name (also removed from the code)

 builder
                .RegisterBlazorMauiWebView()
                .UseMauiApp<App>()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSansRegular.ttf", "OpenSansRegular");
                });

I have a whole bunch of new errors like:

Severity	Code	Description	Project	File	Line	Suppression State
Error	APT2144	invalid file path 'D:\projects\playground\IHostLearning\MauiApp2Blazor\obj\Debug\net6.0-android\res\resources\images\dotnet_bot.svg'.	MauiApp2Blazor	C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-preview.12.2\tools\Xamarin.Android.Aapt2.targets	123	
Error	APT2144	invalid file path 'D:\projects\playground\IHostLearning\MauiApp2Blazor\obj\Debug\net6.0-android\res\resources\appiconfg.svg'.	MauiApp2Blazor	C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-preview.12.2\tools\Xamarin.Android.Aapt2.targets	123	
Error	APT2144	invalid file path 'D:\projects\playground\IHostLearning\MauiApp2Blazor\obj\Debug\net6.0-android\res\resources\fonts\opensansregular.ttf'.	MauiApp2Blazor	C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-preview.12.2\tools\Xamarin.Android.Aapt2.targets	123	
Error	APT2144	invalid file path 'D:\projects\playground\IHostLearning\MauiApp2Blazor\obj\Debug\net6.0-android\res\resources\appicon.svg'.	MauiApp2Blazor	C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-preview.12.2\tools\Xamarin.Android.Aapt2.targets	123	

So something is definitely wrong here, please have a look @jfversluis . Thank you.

So the errors are fixed by steps in https://github.com/dotnet/maui/issues/3900

1reaction
jfversluiscommented, Jan 2, 2022

Hey @ComptonAlvaro thanks for the report!

The error is not about the path where your app is but the filename and if you look at that: OpenSans-Regular.ttf it has a hyphen (-) in there which is not allowed. Android in particular isn’t great at handling “special” characters in filenames, that’s why this safe guard is in place.

Rename that file to, for instance: OpenSansRegular.ttf and it should be fine.

If that doesn’t resolve it, please let me know!

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found