Skip to content

Commit 018c9a4

Browse files
committed
[msbuild] Show an error if SdkDevPath hasn't been set and we're executing a process.
1 parent d360e4b commit 018c9a4

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,10 @@
16201620
<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>
16211621
</data>
16221622

1623+
<data name="E7164" xml:space="preserve">
1624+
<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>
1625+
</data>
1626+
16231627
<data name="E7169" xml:space="preserve">
16241628
<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>
16251629
</data>

msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,23 @@ protected string GetSdkPlatform (bool isSimulator)
111111

112112
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)
113113
{
114-
return ExecuteAsync (Log, fileName, arguments, SdkDevPath, environment, showErrorIfFailure, workingDirectory, cancellationToken);
114+
return ExecuteAsync (this, fileName, arguments, SdkDevPath, environment, showErrorIfFailure, workingDirectory, cancellationToken);
115115
}
116116

117117
static int executionCounter;
118-
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)
118+
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)
119119
{
120+
var log = task.Log;
120121
// Create a new dictionary if we're given one, to make sure we don't change the caller's dictionary.
121122
var launchEnvironment = environment is null ? new Dictionary<string, string?> () : new Dictionary<string, string?> (environment);
122123
if (!string.IsNullOrEmpty (sdkDevPath))
123124
launchEnvironment ["DEVELOPER_DIR"] = sdkDevPath;
124125

126+
if (Environment.OSVersion.Platform == PlatformID.MacOSX && string.IsNullOrEmpty (sdkDevPath)) {
127+
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);
128+
log.LogMessage (MessageImportance.Low, Environment.StackTrace);
129+
}
130+
125131
var currentId = Interlocked.Increment (ref executionCounter);
126132
log.LogMessage (MessageImportance.Normal, MSBStrings.M0001, currentId, fileName, StringUtils.FormatArguments (arguments)); // Started external tool execution #{0}: {1} {2}
127133
if (!string.IsNullOrEmpty (workingDirectory)) {

tests/msbuild/Xamarin.MacDev.Tasks.Tests/TestHelpers/TestBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public virtual void Setup ()
5353
{
5454
var t = new T ();
5555
t.BuildEngine = Engine;
56+
if (t is XamarinTask xt)
57+
xt.SdkDevPath = Configuration.xcode_root;
5658
return t;
5759
}
5860

0 commit comments

Comments
 (0)