Search code examples
visual-studioxamarinxamarin.formsxamarin.androidvisual-studio-mac

The "LinkAssemblies" task failed unexpectedly - SB4018: System.IO.FileNotFoundException


Last week I quite suddenly got this error while building Xamarin.Android for release. Last time I built the project for release everything worked fine.

The projects builds when I choose to link no assemblies, but when I use “Link SDK assemblies only” it fails. And it fails across every branch I have. I have tried to build my master-branch that has not changed since before last time i worked, and that also fails now.

I have also tried to delete bin & obj and checked Android versions and that packages match

Visual Studio is updated, and also have re-installed it, also re-installed Xamarin and Android SDK.

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2145,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamrin.Android.Common.targets(2145,5): error MSB4018: System.IO.FileNotFoundException: Could not load assembly ‘ProjectName.Droid, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?


Solution

  • The solution was to remove <RunCodeAnalysis>true</RunCodeAnalysis> from the android.csproj-file. The problem was that the linker tried linkage before the packages got prepared for linking.