forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AndroidDotnetToolTask] Use full path to dotnet
Context: dotnet/java-interop#988 A recent attempt to update Java.Interop to target net7.0 produced some test failures on the Xamarin.Android side: Using "ClassParse" task from assembly "/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-ci.pr.gh7028.23/tools/Xamarin.Android.Build.Tasks.dll". Task "ClassParse" (TaskId:139) Task Parameter:ToolPath=/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-ci.pr.gh7028.23/tools (TaskId:139) Task Parameter:OutputFile=obj/Debug/api.xml.class-parse (TaskId:139) Task Parameter:SourceJars=/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-ci.pr.gh7028.23/tools/android-support-multidex.jar (TaskId:139) Using: dotnet /Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-ci.pr.gh7028.23/tools/class-parse.dll (TaskId:139) [class-parse] response file: obj/Debug/class-parse.rsp (TaskId:139) --o="obj/Debug/api.xml.class-parse" (TaskId:139) "/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-ci.pr.gh7028.23/tools/android-support-multidex.jar" (TaskId:139) /Users/runner/.dotnet/dotnet /Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-ci.pr.gh7028.23/tools/class-parse.dll "@obj/Debug/class-parse.rsp" (TaskId:139) It was not possible to find any compatible framework version (TaskId:139) The framework 'Microsoft.NETCore.App', version '7.0.0-preview.5.22271.4' (x64) was not found. (TaskId:139) - The following frameworks were found: (TaskId:139) 3.1.1 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] (TaskId:139) 3.1.3 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] (TaskId:139) 3.1.6 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] (TaskId:139) 3.1.25 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] (TaskId:139) 5.0.2 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] (TaskId:139) 5.0.5 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] (TaskId:139) 5.0.8 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] (TaskId:139) 5.0.17 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] (TaskId:139) 6.0.5 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] (TaskId:139) (TaskId:139) You can resolve the problem by installing the specified framework and/or SDK. (TaskId:139) (TaskId:139) The specified framework can be found at: (TaskId:139) - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0-preview.5.22271.4&arch=x64&rid=osx.12-x64 (TaskId:139) 1:7>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-ci.pr.gh7028.23/tools/Xamarin.Android.Bindings.ClassParse.targets(30,5): error MSB6006: "dotnet" exited with code 150. [/Users/runner/work/1/a/TestRelease/05-25_01.03.40/temp/BuildWithExternalJavaLibrary/BuildWithExternalJavaLibraryBinding/BuildWithExternalJavaLibraryBinding.csproj] Commit ff7f467 removed the need to have a global .NET 7 preview install to build and test Xamarin.Android. This appears to expose an issue in `AndroidDotnetToolTask`, which uses the latest `dotnet` in $PATH to run some of our tools. After upgrading some of these tools (class-parse, generator) to net7.0, we are no longer able to run them as there is no net7.0 runtime installed globally. Improve the `AndroidDotnetToolTask` to better handle "sandboxed" .NET installations by using a full path to `dotnet` if one is found.
- Loading branch information
Showing
8 changed files
with
96 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...rin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/AndroidDotnetToolTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
using NUnit.Framework; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using Xamarin.Android.Tasks; | ||
using Xamarin.ProjectTools; | ||
|
||
namespace Xamarin.Android.Build.Tests | ||
{ | ||
[TestFixture] | ||
[Category ("Node-5")] | ||
public class AndroidDotnetToolTests : BaseTest | ||
{ | ||
MockBuildEngine engine; | ||
List<BuildErrorEventArgs> errors; | ||
List<BuildWarningEventArgs> warnings; | ||
List<BuildMessageEventArgs> messages; | ||
|
||
[SetUp] | ||
public void Setup () | ||
{ | ||
engine = new MockBuildEngine (TestContext.Out, | ||
errors: errors = new List<BuildErrorEventArgs> (), | ||
warnings: warnings = new List<BuildWarningEventArgs> (), | ||
messages: messages = new List<BuildMessageEventArgs> ()); | ||
} | ||
|
||
[Test] | ||
public void ShouldUseFullToolPath () | ||
{ | ||
var dotnetDir = AndroidSdkResolver.GetDotNetPreviewPath (); | ||
var dotnetPath = Path.Combine (dotnetDir, (TestEnvironment.IsWindows ? "dotnet.exe" : "dotnet")); | ||
var classParseTask = new ClassParseTestTask { | ||
BuildEngine = engine, | ||
NetCoreRoot = dotnetDir, | ||
ToolPath = Builder.UseDotNet ? TestEnvironment.DotNetAndroidSdkToolsDirectory : AndroidMSBuildDirectory, | ||
ToolExe = Builder.UseDotNet ? "class-parse.dll" : "class-parse.exe", | ||
}; | ||
|
||
Assert.True (classParseTask.Execute (), "Task should have succeeded."); | ||
var expectedTool = Builder.UseDotNet ? dotnetPath : Path.Combine (AndroidMSBuildDirectory, "class-parse.exe"); | ||
Assert.IsTrue (messages.Any (m => m.Message.StartsWith (expectedTool)), "Task did not use expected tool path."); | ||
} | ||
} | ||
|
||
public class ClassParseTestTask : AndroidDotnetToolTask | ||
{ | ||
public override string TaskPrefix => "TEST"; | ||
protected override string GenerateCommandLineCommands () | ||
{ | ||
return GetCommandLineBuilder ().ToString (); | ||
} | ||
} | ||
} |