Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] better ResolveAssemblies errors (#1551)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=7505 Fixes: #1532 In discussion around this issue, we realized the error message given by the `<ResolveAssemblies/>` MSBuild task is confusing. Currently users are currently getting an *unhandled exception* error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'A'. Perhaps it doesn't exist in the Mono for Android profile? File name: 'A.dll' This message makes sense for `System.*` or framework assemblies. We were thinking in some cases we could give an error such as: Could not find assembly A, referenced by B. Please add a NuGet package or assembly reference for A, or remove the reference to B. Additionally we should list an assembly "resolution path", so we can easily figure out where the missing assembly came from. In order to make this work: - Keep a `List<string>` to store the name of each assembly - Catch `FileNotFoundException` specifically - Check `MonoAndroidHelper.IsFrameworkAssembly()` to decide if we show the old message, or the new/improved message - We have to track the `resolutionPath` variable as we go, passing it through recursively as well as removing items as we "un-indent" The full error message will now read: error XA2002: Can not resolve reference `Microsoft.Azure.EventHubs`, referenced by `MyLibrary`. Please add a NuGet package or assembly reference for `Microsoft.Azure.EventHubs`, or remove the reference to `MyLibrary`. If there are multiple assemblies involved you should see something like: error XA2002: Can not resolve reference `Microsoft.Azure.Amqp`, referenced by `MyLibrary` > `Microsoft.Azure.EventHubs`. Please add a NuGet package or assembly reference for `Microsoft.Azure.Amqp`, or remove the reference to `MyLibrary`. Here, `MyLibrary.dll` references `Microsoft.Azure.EventHubs.dll`, which references `Microsoft.Azure.Amqp.dll`, which cannot be found. Other changes: - Added a unit test specifically for the NuGet used in #1532. Tested the scenario where a library project references the broken NuGet, add the `@(ProjectReference)` to the app, then get a different error message. - `StringAssertEx` should give some reasonable default assertion message if `message` is not supplied - `@(PackageReference)` elements had this odd `xmlns=""` attribute, so I included the msbuild XML namespace to fix this - Found an issue in `xabuild.exe` where the NuGet targets were not setup. Most cases of `/t:Restore;Build` seems like they would fail on macOS.
- Loading branch information
1 parent
1ab9c5e
commit 38c365b
Showing
6 changed files
with
129 additions
and
5 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