[macOS]Build may fail if the title contains a slash
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
After upgrading from .NET 8 to .NET 10, the build of one of my MAUI test apps started to fail on MacOS with a `DirectoryNotFoundException` (other targets work):
```
KGySoft.Drawing.Examples.SkiaSharp.Maui net10.0-maccatalyst maccatalyst-x64 failed with 1 error(s) (1,7s) → bin/Debug/net10.0-maccatalyst/maccatalyst-x64/KGySoft.Drawing.Examples.SkiaSharp.Maui.dll
/usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk.net10.0_26.2/26.2.10191/tools/msbuild/Xamarin.Shared.targets(2566,3): error MSB4018:
The "ComputeCodesignItems" task failed unexpectedly.
System.IO.DirectoryNotFoundException: Could not find a part of the path '/Users/username/kgysoft/KGySoft.Drawing/Examples/SkiaSharp.Maui/bin/Debug/net10.0-maccatalyst/maccatalyst-x64/KGy SOFT Drawing SkiaSharp/KGy SOFT Drawing SkiaSharp/MAUI Example.app'.
at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
at System.IO.Enumeration.FileSystemEnumerator`1.Init()
at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options)
at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions enumerationOptions)
at Xamarin.MacDev.Tasks.ComputeCodesignItems.EnumerateAppBundleEntries(String appPath)+MoveNext() in /Users/builder/azdo/_work/2/s/macios/msbuild/Xamarin.MacDev.Tasks/Tasks/ComputeCodesignItems.cs:line 247
at Xamarin.MacDev.Tasks.ComputeCodesignItems.FindFilesToSign(String appPath) in /Users/builder/azdo/_work/2/s/macios/msbuild/Xamarin.MacDev.Tasks/Tasks/ComputeCodesignItems.cs:line 300
at Xamarin.MacDev.Tasks.ComputeCodesignItems.Execute() in /Users/builder/azdo/_work/2/s/macios/msbuild/Xamarin.MacDev.Tasks/Tasks/ComputeCodesignItems.cs:line 115
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
```
After spending many hours with narrowing the issue down, it turned out that the problem is that the `` contained a slash character, which is not escaped when generating the output content.
### Steps to Reproduce
Add a '/' character to the title. Example:
```xml
My SkiaSharp/MAUI Example
```
### Link to public reproduction project repository
https://github.com/koszeggy/KGySoft.Drawing/tree/master/Examples/SkiaSharp.Maui
### Version with bug
10.0.20
### Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
### Last version that worked well
.NET 8 (Please specify exact version)
### Affected platforms
macOS
### Affected platform versions
macOS 26, net10.0-maccatalyst, Microsoft.Maui.Controls 10.0.20
### Did you find any workaround?
An alternative title can be specified for macOS conditionally:
```xml
KGy SOFT Drawing SkiaSharp/MAUI Example
KGy SOFT Drawing SkiaSharp-MAUI Example
```
### Relevant log output
```shell
Open the collapsible Details section in Description above
```
Contributor guide
Research direction
Start with Xamarin.Shared.targets around line 2566 and ComputeCodesignItems.cs at lines 115, 247, and 300, then reproduce using the linked SkiaSharp.Maui project with an ApplicationTitle containing '/'. Trace how the title reaches the app bundle path and verify that the macOS build completes successfully without the DirectoryNotFoundException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system, desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100