Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,10 @@
<value>Unable to copy the inputs to this task to the remote build server for unknown reasons. The build log may have more information.</value>
</data>

<data name="E7164" xml:space="preserve">
<value>The task '{0}' is trying to call an external process, but a path to Xcode has not been provided. Please file an issue at https://github.com/dotnet/macios/issues/new/choose.</value>
</data>

<data name="E7169" xml:space="preserve">
<value>The task '{0}' requires the property '{1}' to be set. Please file an issue at https://github.com/dotnet/macios/issues/new/choose.</value>
</data>
Expand Down
10 changes: 8 additions & 2 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,23 @@ protected string GetSdkPlatform (bool isSimulator)

internal protected System.Threading.Tasks.Task<Execution> ExecuteAsync (string fileName, IList<string> arguments, Dictionary<string, string?>? environment = null, bool showErrorIfFailure = true, string? workingDirectory = null, CancellationToken? cancellationToken = null)
{
return ExecuteAsync (Log, fileName, arguments, SdkDevPath, environment, showErrorIfFailure, workingDirectory, cancellationToken);
return ExecuteAsync (this, fileName, arguments, SdkDevPath, environment, showErrorIfFailure, workingDirectory, cancellationToken);
}

static int executionCounter;
static async System.Threading.Tasks.Task<Execution> ExecuteAsync (TaskLoggingHelper log, string fileName, IList<string> arguments, string? sdkDevPath = null, Dictionary<string, string?>? environment = null, bool showErrorIfFailure = true, string? workingDirectory = null, CancellationToken? cancellationToken = null)
static async System.Threading.Tasks.Task<Execution> ExecuteAsync (Task task, string fileName, IList<string> arguments, string? sdkDevPath = null, Dictionary<string, string?>? environment = null, bool showErrorIfFailure = true, string? workingDirectory = null, CancellationToken? cancellationToken = null)
{
var log = task.Log;
// Create a new dictionary if we're given one, to make sure we don't change the caller's dictionary.
var launchEnvironment = environment is null ? new Dictionary<string, string?> () : new Dictionary<string, string?> (environment);
if (!string.IsNullOrEmpty (sdkDevPath))
launchEnvironment ["DEVELOPER_DIR"] = sdkDevPath;

if (Environment.OSVersion.Platform == PlatformID.MacOSX && string.IsNullOrEmpty (sdkDevPath)) {
log.LogError (MSBStrings.E7164 /* The task '{0}' is trying to call an external process, but a path to Xcode has not been provided. Please file an issue at https://github.com/dotnet/macios/issues/new/choose. */, task.GetType ().Name);
log.LogMessage (MessageImportance.Low, Environment.StackTrace);
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging Environment.StackTrace here will show the stack from where Environment class is called, not the actual call stack leading to this error. Consider using new StackTrace().ToString() instead to get the actual call stack, which would be more useful for debugging.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After logging the error about the missing SdkDevPath, the code continues to execute the external process, which will likely fail or produce confusing errors. Consider returning early after logging the error to prevent cascading failures and make the error message clearer. This could be done by returning a failed Execution object or throwing an exception that gets caught by the caller.

Suggested change
log.LogMessage (MessageImportance.Low, Environment.StackTrace);
log.LogMessage (MessageImportance.Low, Environment.StackTrace);
throw new InvalidOperationException ("The task is trying to call an external process, but a path to Xcode has not been provided.");

Copilot uses AI. Check for mistakes.
}

var currentId = Interlocked.Increment (ref executionCounter);
log.LogMessage (MessageImportance.Normal, MSBStrings.M0001, currentId, fileName, StringUtils.FormatArguments (arguments)); // Started external tool execution #{0}: {1} {2}
if (!string.IsNullOrEmpty (workingDirectory)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public virtual void Setup ()
{
var t = new T ();
t.BuildEngine = Engine;
if (t is XamarinTask xt)
xt.SdkDevPath = Configuration.xcode_root;
return t;
}

Expand Down
Loading