Skip to content

Commit

Permalink
[msbuild] Don't try to run 'dotnet build' if 'dotnet restore' failed …
Browse files Browse the repository at this point in the history
…in the XamarinBuild task. (#18620)

This avoids throwing spurious exceptions when we blinding keep executing
stuff that doesn't make sense anymore.
  • Loading branch information
rolfbjarne committed Aug 9, 2023
1 parent 0590d65 commit 092e2ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/FindAotCompilerTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public override bool Execute ()
AotCompiler = ComputeValueUsingTarget (target, targetName);
}

// Don't check if the aot compiler exists if an error was already reported.
if (Log.HasLoggedErrors)
return false;

if (!File.Exists (AotCompiler))
Log.LogError (MSBStrings.E7081 /*"The AOT compiler '{0}' does not exist." */, AotCompiler);

Expand Down
4 changes: 4 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/FindILLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public override bool Execute ()

var illinkTaskPath = ComputeValueUsingTarget (target, targetName);

// Don't do anything else if something already went wrong (in particular don't check if illink.dll exists).
if (Log.HasLoggedErrors)
return false;

if (!string.IsNullOrEmpty (illinkTaskPath))
ILLinkPath = Path.Combine (Path.GetDirectoryName (illinkTaskPath), "illink.dll");

Expand Down
4 changes: 4 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinBuildTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ protected string ComputeValueUsingTarget (string computeValueTarget, string targ
try {
ExecuteRestoreAsync (dotnetPath, projectPath, targetName, environment).Wait ();

// Don't try to run 'dotnet build' if restore failed.
if (Log.HasLoggedErrors)
return string.Empty;

return ExecuteBuildAsync (dotnetPath, projectPath, targetName, environment).Result;
} finally {
if (KeepTemporaryOutput) {
Expand Down

5 comments on commit 092e2ba

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.