We can only have one .targets file in a nupkg that gets auto-imported into the project (it must be named nuget-package-id.targets), and since some of our packages already were using this file, we need to merge the generated targets for Xamarin.Build.Download with these files. This means the custom build tasks must be built before the nuget-setup task runs. This changes the build script to build the existing custom tasks, copy their .targets files, and then detect them when generated the .targets files for Xamarin.Build.Download, and merge them together.
Previously the XamarinBuildDownloadPartialZip item was getting added if the .aar wasn’t in the Android SDK location. If the .aar exists already in the download cache, we were still running the task to look for this item. Now the task would figure out quickly the item didn’t need downloading and was already cached, but with this changed condition we don’t even have to go that far to figure out it’s not needed.
Moved the XamarinBuildDownload item declaration into the restore target so that it’s evaluated later in the build (so $(AndroidSdkDirectory) will be populated).
$AndroidSdkPath and $AndroidSdkDirectory weren’t being evaluated early enough to be used in properties (so the value would be blank). This works around that by evaluating conditions using the android sdk location later (eg: not putting the $AndroidSdkDirectory into a property which is then later used in a condition). Also, the full path now gets updated in the Task if the .aar file does exist in the android sdk.