New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[build] msbuild /t:Prepare Xamarin.Android.sln
hits ""ResolveAndroidTooling" task failed unexpectedly." with Visual Studio 2017 version 15.9 Preview if $(AndroidToolchainDirectory)
doesn't already exist
#2195
Comments
/cc @jonathanpeppers, for whenever you have a moment, so I can have you sanity-check if it sounds reasonable to paste those 2 lines from |
So I guess I haven't run into this, because I don't set Basically you could boil it down to:
I'm not sure what the best fix is here... If you took your example: AndroidSdkPath = MonoAndroidHelper.AndroidSdk.AndroidSdkPath; I'm guessing this works because it goes and finds some Android SDK somewhere, could you have one from the VS install? I also wouldn't want to do this, as it's going to go "find" an SDK instead of the one supplied by the setting in the IDE in customer apps. Your other idea about reordering stuff seems a bit safer, but we might have a chicken-and-egg scenario. We had to work around something like this for NuGet when we introduced I would rather get rid of 41a4cbc in favor of something less hacky, maybe could fix this scenario at the same time? Need to think about it. |
I realized overnight that this condition isn't necessary, and so there is in fact a way to hit the issue in end-user app builds too: #2200. I'm assuming that since |
|
We believe this fixes it: #2204 @brendanzagaeski feel free to reopen if you find something new here. |
This is a new error that happens when running
msbuild /t:Prepare Xamarin.Android.sln
using Visual Studio 2017 version 15.9 Preview or higher (any version that includes d73442e).The error doesn't happen when building with Visual Studio 2017 version 15.8 because in that version
GetMaxInstalledApiLevel()
was directly part of a single largeResolveSdkTask
where$(AndroidSdkPath)
was set toMonoAndroidHelper.AndroidSdk.AndroidSdkPath
(C:\Program Files (x86)\Android\android-sdk in my test environment). AlthoughResolveSdkTask
itself still usesMonoAndroidHelper.AndroidSdk.AndroidSdkPath
in Visual Studio 2017 version 15.9 Preview, the newResolveAndroidTooling
task does not currently useMonoAndroidHelper
, so$(AndroidSdkPath)
stays set to$(AndroidToolchainDirectory)
(C:\src\android-toolchain in my test environment). WhenGetMaxInstalledApiLevel()
callsDirectory.EnumerateDirectories()
on the Android SDK in the program files directory, it works because that directory exists, but when it tries to enumerate C:\src\android-toolchain, it hits an error because that directory does not yet exist. (The next step of the build just after the NuGet packages are restored is to set up that directory.)Possible Fix
One possible way to resolve this issue is to have
ResolveAndroidTooling
useMonoAndroidHelper.AndroidSdk.AndroidSdkPath
:I tested this locally, and it worked as desired for this scenario. I believe this should be OK for end-user Xamarin.Android app builds too because it's just going back to how these paths were determined at this step in Visual Studio 2017 version 15.8.
Other possibles approaches
I initially tried moving
<MSBuild Projects="$(MSBuildThisFileDirectory)..\android-toolchain\android-toolchain.csproj" />
to happen before the NuGet restore commands, but that was unsuccessful due to missing dependencies. It might be possible to adjust android-toolchain.csproj and the other preparation steps so that android-toolchain.csproj can build before anyNuGet.exe restore
step (or more precisely, before anyNuGet.exe restore
on a project that imports Xamarin.Android.Common.targets), but I haven't experimented with that.Steps to Reproduce
Install Visual Studio 2017 version 15.9 Preview 2 or higher with the Mobile development with .NET workload. Also select the following Individual components:
git clone https://github.com/xamarin/xamarin-android.git
Ensure that you do not yet have an android-toolchain directory from a previous
msbuild /t:Prepare Xamarin.Android.sln
. (Or rename the existing directory out of the way.)msbuild Xamarin.Android.sln /t:Prepare
If Visual Studio version 15.8 is also installed, then NuGet will default to using the MSBuild and Xamarin.Android.Common.targets file from that version, and the
/t:Prepare
target will succeed. In that case you can invoke NuGet directly instead, passing in the path to MSBuild from the Visual Studio preview version:.\.nuget\NuGet.exe restore .\Xamarin.Android-Tests.sln -MSBuildPath "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\15.0\bin"
Expected Behavior
The NuGet restore step succeeds.
Actual Behavior
The NuGet restore step fails for Xamarin.Android-Tests.sln at the point where
_SetLatestTargetFrameworkVersion
calls the newResolveAndroidTooling
task.The text was updated successfully, but these errors were encountered: