Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project names containing a valid characters now cause errors on project generation (for iOS or MacCatalyst, and Android) #26645

Open
mrlacey opened this issue Dec 15, 2024 · 2 comments
Labels
t/bug Something isn't working

Comments

@mrlacey
Copy link
Contributor

mrlacey commented Dec 15, 2024

Description

Previously valid characters included on the project or solution name are now causing the iOS and MacCatalyst versions of apps to fail to build.

Ok, so the "valid" characters in question are ones you might not expect, but this still leads to weird exception messages.

The valid characters in question are:

  • Underscore _
  • At sign @
  • Open bracket (
  • Close bracket )

These are all "technically" valid characters in a project name but have started to cause issues with iOS and Mac Catalyst compilation in the latest VS previews. (And, presumably the .net 9 previews too)

When a project is created that includes one of these characters in the project or solution name, the newly generated project immediately reports errors (due to a failed design time compilation.)

These characters did not cause a problem previously.

While the above characters aren't valid in types and namespaces, they are all correctly substituted with underscores in code files.

It's not an issue with the project or solution settings. The problem is the use of these characters inside the file path.
It's possible to create directory that includes one or more of these characters and then create a project in that location that only includes alphanumeric characters but still produces the same errors.

I expect a change has been made with the mac/iOS tooling that doesn't correctly escape file paths.

X-Ref: #23839 and #26486 (similar issues relating to the inclusion of an underscore but only affecting Windows)

For additional reference, I have the following installed:

> dotnet --list-sdks
3.1.426 [C:\Program Files\dotnet\sdk]
5.0.104 [C:\Program Files\dotnet\sdk]
5.0.214 [C:\Program Files\dotnet\sdk]
5.0.302 [C:\Program Files\dotnet\sdk]
5.0.303 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
5.0.416 [C:\Program Files\dotnet\sdk]
6.0.202 [C:\Program Files\dotnet\sdk]
6.0.203 [C:\Program Files\dotnet\sdk]
6.0.321 [C:\Program Files\dotnet\sdk]
6.0.401-faulty [C:\Program Files\dotnet\sdk]
6.0.428 [C:\Program Files\dotnet\sdk]
7.0.317 [C:\Program Files\dotnet\sdk]
9.0.101 [C:\Program Files\dotnet\sdk]
9.0.200-preview.0.24575.35 [C:\Program Files\dotnet\sdk]

Steps to Reproduce

  1. Using Visual Studio Version 17.13.0 Preview 2.0
  2. File > New .NET MAUI App
  3. Set Project name to Maui_@()App
  4. Use .NET 9.0
  5. Do NOT include sample content
  6. Click "Create"
  7. When the project opens in VS, wait a few seconds and then see errors:

An error occurred during a design-time build. Some features may not work correctly. See the Error List for details.

The Error List includes:

Severity	    Code	    Description	                                                                                                            Project	                            File	                                                                           
Error (active)	NETSDK1082	There was no runtime pack for Microsoft.NETCore.App available for the specified RuntimeIdentifier 'iossimulator-x64'.	Maui_@()App (net9.0-ios)        	C:\Program Files\dotnet\sdk\9.0.200-preview.0.24575.35\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets	495		

Error (active)	NETSDK1082	There was no runtime pack for Microsoft.NETCore.App available for the specified RuntimeIdentifier 'maccatalyst-x64'.	Maui_@()App (net9.0-maccatalyst)	C:\Program Files\dotnet\sdk\9.0.200-preview.0.24575.35\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets	495		

Expected: the generated project should load without issue.

Note that the Windows version of the generated project will build and run without issue.

The Android version of the project fails to build with XAPRAS7004

System.ArgumentException: must not be null or empty
Parameter name: abi
   at Xamarin.Android.Tasks.ProcessAssemblies.SetAssemblyAbiMetadata(String abi, ITaskItem assembly, ITaskItem symbol) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs:line 103
   at Xamarin.Android.Tasks.ProcessAssemblies.SetMetadataForAssemblies(List`1 output, Dictionary`2 symbols) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs:line 128
   at Xamarin.Android.Tasks.ProcessAssemblies.RunTask() in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs:line 62
   at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25

No project repro link included as it happens on new project generation. - I can add one if it will really make a difference.

Link to public reproduction project repository

No response

Version with bug

9.0.21 SR2.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.0 GA

Affected platforms

macOS, iOS, Android

Affected platform versions

No response

Did you find any workaround?

The workaround is to not have these characters in the file paths of anything included in the solution.

I assume this will be very low priority but it would be good if the project name validation could be updated when creating a new project and/or if the error messages displayed could better point to the real cause of the issue.

Relevant log output

@mrlacey mrlacey added the t/bug Something isn't working label Dec 15, 2024
@mrlacey
Copy link
Contributor Author

mrlacey commented Dec 15, 2024

On a related note, I've also discovered that in the latest preview, VS can't cope with relative project paths that contain spaces when creating links between projects in the same solution.
Maybe it would be easier if MAUI enforced only alphanumeric characters (and dot/period) in all file names and paths.

@kevinxufei
Copy link

@mrlacey We have discussed this issue in #26092. Actually, these errors are caused by special characters in project name. If you have no other questions, we will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants