0
votes

I'm getting this error on Release build when I use an obfuscator (.NET Reactor):

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: System.ArgumentException: Empty name

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.Mixin.CheckName(String name)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.ModuleDefinition.GetType(String namespace, String name)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.MetadataResolver.GetTypeDefinition(ModuleDefinition module, TypeReference type)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.MetadataResolver.GetType(ModuleDefinition module, TypeReference reference)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.TypeReference.Resolve()

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Linker.Steps.SweepStep.ResolveAllTypeReferences(AssemblyDefinition assembly)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Linker.Steps.SweepStep.Process()

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Linker.Steps.BaseStep.Process(LinkContext context)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

I'm using Visual Studio 2015 with Xamarin extension for Visual Studio v4.2.2.11 (file Xamarin.VisualStudio_4.2.2.11.msi), Xamarin Android v7.0.2.42, MSBuild 2015 and .NET Reactor. Project is setup to use .NET FX v4.6.1 and Android Target v5.1 (API 22) and minimum version v4.4 (API 19).

Since I was getting this on my project, I tested this by creating a blank Android project without any code added to it, just the code created by the new blank project (button click) so there are no references to DLLs or 3rd party components.

Regards,

NCruz

1
Update: I edited the version of Xamarin Android as I had originally stated it was v4.2.2.11 which was the version for Xamarin extension for Visual Studio. The correct version of Xamarin Android I am using is v7.0.2.42ncruz
You'd better contact Xamarin support. The call stack shows a Mono.Cecil issue so it must be related to the assemblies you added as references. If they have been obfuscated in certain ways, such issues are expected.Lex Li
I contacted Xamarin support and the person said that they don't have technical/dev support as they've been absorbed into the Visual Studio team. I did not add any assembly references - it's a blank Android project with no code added, just clicked on 'New Project' and chose 'Blank Android Project'. What does Mono.Cecil function with assembly references? I notice that the call stack has a 'System.ArgumentException: Empty name' error at Mono.Cecil.Mixin.CheckName(String name) .ncruz
Can you uninstall the obfuscator? It is well known that Mono.Cecil (which I guess is used in the linker) does not work quite well with obfuscated assemblies.Lex Li
I call the obfuscator from MSBuild. In my csproj file I hook into the 'AfterCompile' event (<Target Name="AfterCompile"><Exec Command="..."></Target>). The obfuscator does its thing then replaces the DLL with the obfuscated one. If I take out that event hook, the build works fine.ncruz

1 Answers

0
votes

I credit this answer to Lex Li who pointed out that I should try to disable each of the obfuscation features, and see which triggers the linker issue. There are several command line switches that I use to activate certain obfuscation features like so: -suppressildasm 1 -obfuscation 1 -stringencryption 1 -antitamp 1 ..etc. At first, I removed/deleted them all from the command line but it still had the error. Then I put them all back and instead put 0 instead of 1 (-suppressildasm 0) to deactivate each function. The suppressildasm feature was the one causing the error.