Skip to content

Fix ArgumentNullException in AppleSdkSettings when no settings file exists#179

Merged
dalexsoto merged 1 commit into
mainfrom
dev/alex/fix-check
May 12, 2026
Merged

Fix ArgumentNullException in AppleSdkSettings when no settings file exists#179
dalexsoto merged 1 commit into
mainfrom
dev/alex/fix-check

Conversation

@dalexsoto

Copy link
Copy Markdown
Member

The static constructor iterates over SettingsPathCandidates looking for an existing settings file (maui/Settings.plist or Xamarin/Settings.plist). When neither file exists — which happens on fresh machines or CI agents that have never configured an Xcode path — SettingsPath remains null.

This causes Directory.CreateDirectory(Path.GetDirectoryName(null)) to throw System.ArgumentNullException at line 145 (parameter 'path'), which propagates as a TypeInitializationException and ultimately fails the DetectSdkLocations MSBuild task, breaking all builds.

Fix: after the loop, if no existing settings file was found, default SettingsPath to the first candidate (~/Library/Preferences/maui/Settings.plist). This ensures the directory is created and Init() can proceed to discover Xcode via xcode-select or other fallback mechanisms.

…xists

The static constructor iterates over SettingsPathCandidates looking for
an existing settings file (maui/Settings.plist or Xamarin/Settings.plist).
When neither file exists — which happens on fresh machines or CI agents
that have never configured an Xcode path — SettingsPath remains null.

This causes Directory.CreateDirectory(Path.GetDirectoryName(null)) to
throw System.ArgumentNullException at line 145 (parameter 'path'), which
propagates as a TypeInitializationException and ultimately fails the
DetectSdkLocations MSBuild task, breaking all builds.

Fix: after the loop, if no existing settings file was found, default
SettingsPath to the first candidate (~/Library/Preferences/maui/Settings.plist).
This ensures the directory is created and Init() can proceed to discover
Xcode via xcode-select or other fallback mechanisms.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dalexsoto dalexsoto requested a review from rolfbjarne May 12, 2026 15:24
@dalexsoto dalexsoto merged commit 95ec821 into main May 12, 2026
7 checks passed
@dalexsoto dalexsoto deleted the dev/alex/fix-check branch May 12, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants