android: Extraneous "The "FilterAssemblies" task failed unexpectedly" error appears for builds inside Visual Studio if an app references a .NET Standard library that did not build successfully
This is a possible area for follow-up related to https://github.com/xamarin/xamarin-android/pull/2795.
In my testing so far, this only seemed to affect builds that happened within Visual Studio. Command line builds aborted after they hit the error in the .NET Standard library, so they didn’t attempt to run any targets in the Android app project.
Steps to reproduce
Build the attached test case within Visual Studio 2019 version 16.2 or higher.
Test case: FilterAssembliesAfterError.zip
Expected behavior
One of the following:
-
The Android app build aborts with no errors.
This is what now happens in Visual Studio 2019 version 16.2 if there are syntax errors in a referenced Android library project (in contrast to a .NET Standard library project). This has a nice consequence that only the errors from the Android class library project appear in the Error List.
-
Or the build proceeds all the way to the
CoreCompiletarget so thatcscemits an error.This is what happens for a .NET Core app that references a .NET Standard library that contains syntax errors.
-
Or, if neither of those options is easy to do, maybe the build could fail with the old
LinkAssembliestask error orResolveLibraryProjectsImporttask error for this particular scenario. That way, the error message would at least be familiar for existing users.
Actual behavior
The app project emits an extraneous build error that is also unfamiliar because it did not exist in previous versions of Xamarin.Android:
error MSB4018: The "FilterAssemblies" task failed unexpectedly.
System.IO.FileNotFoundException: Could not find file 'C:\Temp\FilterAssembliesAfterError\NetStandardLibrary1\bin\Debug\netstandard2.0\NetStandardLibrary1.dll'.
File name: 'C:\Temp\FilterAssembliesAfterError\NetStandardLibrary1\bin\Debug\netstandard2.0\NetStandardLibrary1.dll'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Xamarin.Android.Tasks.FilterAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\Temp\FilterAssembliesAfterError\AndroidApp1\AndroidApp1.csproj]
Log file
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 23 (10 by maintainers)
Release status update
A new Preview version has now been published on Windows that includes the fix to produce the standard Metadata file … could not be found error message for this scenario. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.
The fix is not yet available on macOS. I will update this item again when a Preview version with the fix is available on macOS.
Fix included in Xamarin.Android 10.2.0.16.
Fix included on Windows in Visual Studio 2019 version 16.5 Preview 1. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.
Fix not yet available on macOS.
Cross-referencing notes for the team
The behavior of this scenario is improved in Visual Studio 2019 version 16.4 Preview by https://github.com/xamarin/xamarin-android/pull/3609. In that version, the error message no longer starts with the misleading mention of FilterAssemblies.
The behavior is fully fixed in the d16-5 development builds by https://github.com/xamarin/xamarin-android/pull/3720. Once the change from that pull request is published, this scenario will produce the standard Metadata file … could not be found error from the
CoreCompiletarget as seen for other C# project types like .NET Core console apps.@moniquealtero, what you’re seeing is a bit different.
This issue is about the scenario where the “LinkAssemblies” error appears together with a
FileNotFoundException, like:System.IO.FileNotFoundException: Could not find file 'C:\Temp\FilterAssembliesAfterError\NetStandardLibrary1\bin\Debug\netstandard2.0\NetStandardLibrary1.dll'.What you’re seeing is that the linker is finding all of the assemblies, but it’s not able to resolve one of the types within one of the assemblies:
Mono.Linker.MarkException: Error processing method: 'System.Void Unio.App.Forms.Droid.Resource::UpdateIdValues()' in assembly: 'Unio.App.Forms.Droid.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Int32 MvvmCross.Droid.Support.Design.Resource/Animation::tooltip_enterOne common cause of resolution errors like that is if some NuGet packages referenced by the project are out-of-date. If updating the NuGet packages doesn’t help, and you get stuck on that error, please do submit a new issue to describe your scenario so the team can take a look. Thanks in advance!
@Im-PJ , I’m not sure what circumstances would be most likely to produce this error if it is not accompanied by other errors. If you could submit a new issue with the full text of the error you are seeing, plus the saved diagnostic MSBuild output or a zipped up test case that demonstrates the issue so the team can investigate further, that would be perfect. Thanks in advance!