dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 528 forks source link

The SDK Microsoft.NET.Runtime.MonoAOTCompiler.Task could not be found. #9176

Open gmck opened 2 months ago

gmck commented 2 months ago

Android framework version

net8.0-android

Affected platform version

VS 2022 17.10.5

Description

When I try and clone the GitHub repo of my app on a second machine I always get the above error. The same thing happens if I download it as a zip. The file exists at C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets. Tried with VS preview versions as well and the same problem.

The app builds fine on my machine. I've deleted the repo and recreated it and it still fails

Steps to Reproduce

As above

Did you find any workaround?

No

Relevant log output

n/a
dellis1972 commented 2 months ago

Do you have a binlog?

Have you tried clearing the nuget cache? A quick google search suggests that might help.

gmck commented 2 months ago

bin_gmck.zip @dellis1972 This build is ok with VS on my main machine.

I tried building on my machine where I haven't had any problems building using VS. So I tried VS Code terminal with dotnet build OBDNowPros.csproj -bl and got the same error. This was after I had used Clear All NuGet Storage and rebuilt with VS. After the Nuget stuff I also got the same error rebuilding. Cleaned again and it was rebuilt correctly as above.

A quick google search suggests that might help. Didn't help me when I searched.

dellis1972 commented 2 months ago

@gmck the only way I can repo you issue is it I don't have the following in the project. (this is when building for release)

<RunAOTCompilation>true</RunAOTCompilation>

jonathanpeppers commented 2 months ago

Microsoft.NET.Runtime.MonoAOTCompiler.Task is part of the Mono workload that the Android workload depends on.

If this only happens on one machine, it's probably related to .NET workloads having some install failure.

If you follow this to get your machine to a clean state:

Then install the .NET MAUI workload in Visual Studio again, does the problem go away?

gmck commented 2 months ago

@dellis1972 I have that true because I'm trying to use dotnet trace to collect a speedscope file - following Jonathon's video. I first hit this performance problem about a year ago see #8285. I gave up on net8.0-android back then and went back to X.A. to get my app (Android 14) into production. Now I'm back converting it to net8.0-android and the performance is just as bad as it was last year.

@jonathanpeppers - I'm not interested in Maui, only Android, so do you still want me to do all that maui stuff?

jonathanpeppers commented 2 months ago

@gmck it depends on how you installed, did you use command-line or the Visual Studio installer? If you used Visual Studio, then there is only a top-level MAUI Visual Studio workload to choose from.

gmck commented 2 months ago

Initially used VS installer. However, when it came to net8-android last year, I used your release notes which was the command-line. Very rarely do anything with the command-line. All upgrades to VS since on my machine have been VS.

jonpryor commented 2 months ago

Please provide the requested .binlog.

gmck commented 2 months ago

@jonpryor I provided a binlog in response to @dellis1972. My apologies; I should have reported back. I solved the problem on my secondary machine, by uninstalling Visual Studio 2022 and VS Code. When reinstalled today with only Visual Studio 2022 17.12.0 Prev 1.0, I could recreate the project via Clone Repository and successfully build it. At this stage, I haven't got around to reinstalling VS Code on that machine.