I am trying to build old code with Visual Studio For Mac and getting the following error:
Target XamlC:
Compiling Xaml
Assembly: obj/Debug/OxyPlot.Xamarin.Forms.dll
...
/Users/.../MyProject/packages/Xamarin.Forms.2.3.3.193/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20/Xamarin.Forms.targets(62,3): error MSB4018: The "XamlCTask" task failed unexpectedly.
/Users/.../MyProject/packages/Xamarin.Forms.2.3.3.193/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20/Xamarin.Forms.targets(62,3): error MSB4018: System.IO.FileNotFoundException: Could not find file "/Users/.../MyProject/OxyPlot/OxyPlot.Xamarin.Forms/obj/Debug/OxyPlot.Xamarin.Forms.dll.mdb"
/Users/.../MyProject/packages/Xamarin.Forms.2.3.3.193/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20/Xamarin.Forms.targets(62,3): error MSB4018: File name: '/Users/.../MyProject/OxyPlot/OxyPlot.Xamarin.Forms/obj/Debug/OxyPlot.Xamarin.Forms.dll.mdb'
/Users/.../MyProject/packages/Xamarin.Forms.2.3.3.193/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20/Xamarin.Forms.targets(62,3): error MSB4018:
/Users/.../MyProject/packages/Xamarin.Forms.2.3.3.193/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20/Xamarin.Forms.targets(62,3): error MSB4018:
/Users/.../MyProject/packages/Xamarin.Forms.2.3.3.193/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20/Xamarin.Forms.targets(62,3): error MSB4018: Server stack trace:
...
I read here, that it is possible to use elder Mono (4.8) to build project. How to do this?
I just tried adding a Fody NuGet package to my C# project and now anytime I try to build I get the following error.
error MSB4018: The "ResolveAssemblyReference" task failed unexpectedly.
error MSB4018: System.Security.SecurityException: Invalid assembly public key. (Exception from HRESULT: 0x8013141E)
error MSB4018: at System.Reflection.AssemblyName.nToString()
error MSB4018: at System.Reflection.AssemblyName.get_FullName()
error MSB4018: at Microsoft.Build.Tasks.ReferenceTable.MarkReferencesForExclusion(Dictionary`2 exclusionList)
error MSB4018: at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute(FileExists fileExists, DirectoryExists directoryExists, GetDirectories getDirectories, GetAssemblyName getAssemblyName, GetAssemblyMetadata getAssemblyMetadata, GetRegistrySubKeyNames getRegistrySubKeyNames, GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, GetLastWriteTime getLastWriteTime, GetAssemblyRuntimeVersion getRuntimeVersion, OpenBaseKey openBaseKey, GetAssemblyPathInGac getAssemblyPathInGac, IsWinMDFile isWinMDFile, ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader)
error MSB4018: at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute()
error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
error MSB4018: The Zone of the assembly that failed was:
error MSB4018: MyComputer
I've tried uninstalling and re-installing, different add-ins/weavers. It always ends up with the same result. My solution has two projects, a .NET Standard 2.0 library and a .NET Framework 4.6.1 class library containing unit tests. The Standard library builds but the unit test project is the one failing.
I'm trying to follow the instructions in Microsoft's document Code Generation
in a Build Process to rebuild T4 templates on our build server. When
I build, template generation is failing with the error (the full MSBuild output
is later in this question):
error MSB4018: The "TransformTemplates" task failed unexpectedly.
error MSB4018: System.IO.FileNotFoundException: Could not load file or
assembly 'Microsoft.VisualStudio.TextTemplating.14.0, Version=14.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
The system cannot find the file specified.
I created a minimal project that reproduces the problem. The script
build.cmd simply executes MSBuild. When I run build.cmd from my
workstation, the build succeeds. It only fails on the build server.
Things I've tried:
Copied the MSBuild and Visual Studio assemblies to the build server, as
specified by the Code Generation document.
Added the Visual Studio assemblies to the GAC.
Set the VSSDK140Install environment variable to "C:\Program Files
(x86)\Microsoft Visual Studio 14.0\VSSDK\" (because that's how it's set on
my workstation).
Set HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0!InstallDir to
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\
I'm trying to avoid installing Visual Studio 2015, because that's a pretty
large dependency to add to our build server, and the Microsoft documentation
explicitly says this should be possible.
Copied assemblies to C:\Program Files (x86)
I've copied the following files to the build server, as specified in the Code
Generation document (these are all in the Program Files (x86) folder, since
that's where they are on my machine):
$(ProgramFiles)\MSBuild\Microsoft\VisualStudio\v*.0\TextTemplating
Microsoft.VisualStudio.TextTemplating.Sdk.Host.14.0.dll
Microsoft.TextTemplating.Build.Tasks.dll
Microsoft.TextTemplating.targets
$(ProgramFiles)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0
Microsoft.VisualStudio.TextTemplating.14.0.dll
Microsoft.VisualStudio.TextTemplating.Interfaces.14.0.dll (several files)
Microsoft.VisualStudio.TextTemplating.VSHost.14.0.dll
$(ProgramFiles)\Microsoft Visual Studio 14.0\Common7\IDE\PublicAssemblies\
Microsoft.VisualStudio.TextTemplating.Modeling.14.0.dll
Added to the GAC
I saw it's failing trying to load
Microsoft.VisualStudio.TextTemplating.14.0.dll, and since that assembly is in
the GAC on my workstation I guessed maybe that was required, so I tried using
GAC Manager to add
Microsoft.VisualStudio.TextTemplating.14.0.dll to the GAC, but the error is
the same.
The full MSBuild output
When I run build.cmd, I get the following output:
D:\TTTest>"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" ClassLibrary1.sln /t:Rebuild
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 10/20/2017 11:05:16 AM.
Project "D:\TTTest\ClassLibrary1.sln" on node 1 (Rebuild target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "D:\TTTest\ClassLibrary1.sln" (1) is building "D:\TTTest\ClassLibrary1\ClassLibrary1.csproj" (2) on node 1 (Rebuild target(s)).
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: The "TransformTemplates" task failed unexpectedly. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TextTemplating.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: File name: 'Microsoft.VisualStudio.TextTemplating.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: at Microsoft.VisualStudio.TextTemplating.Sdk.Host.GenericTextTemplatingHost..ctor(IServiceProvider serviceProvider) [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: at Microsoft.VisualStudio.TextTemplating.Build.Tasks.TransformTemplatesBase.GetConfiguredTextTemplatingHost() [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: at Microsoft.VisualStudio.TextTemplating.Build.Tasks.TransformTemplatesBase.Execute() [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: === Pre-bind state information === [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: DisplayName = Microsoft.VisualStudio.TextTemplating.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: (Fully-specified) [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Appbase = file:///C:/Program Files (x86)/MSBuild/14.0/Bin/ [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Initial PrivatePath = NULL [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: Calling assembly : Microsoft.VisualStudio.TextTemplating.Sdk.Host.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: === [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: This bind starts in LoadFrom load context. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Using application configuration file: C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe.Config [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Using host configuration file: [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Post-policy reference: Microsoft.VisualStudio.TextTemplating.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/14.0/Bin/Microsoft.VisualStudio.TextTemplating.14.0.DLL. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/14.0/Bin/Microsoft.VisualStudio.TextTemplating.14.0/Microsoft.VisualStudio.TextTemplating.14.0.DLL. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/14.0/Bin/Microsoft.VisualStudio.TextTemplating.14.0.EXE. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/14.0/Bin/Microsoft.VisualStudio.TextTemplating.14.0/Microsoft.VisualStudio.TextTemplating.14.0.EXE. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/Microsoft/VisualStudio/v14.0/TextTemplating/Microsoft.VisualStudio.TextTemplating.14.0.DLL. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/Microsoft/VisualStudio/v14.0/TextTemplating/Microsoft.VisualStudio.TextTemplating.14.0/Microsoft.VisualStudio.TextTemplating.14.0.DLL. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/Microsoft/VisualStudio/v14.0/TextTemplating/Microsoft.VisualStudio.TextTemplating.14.0.EXE. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/Microsoft/VisualStudio/v14.0/TextTemplating/Microsoft.VisualStudio.TextTemplating.14.0/Microsoft.VisualStudio.TextTemplating.14.0.EXE. [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error MSB4018: [D:\TTTest\ClassLibrary1\ClassLibrary1.csproj]
Done Building Project "D:\TTTest\ClassLibrary1\ClassLibrary1.csproj" (Rebuild target(s)) -- FAILED.
Done Building Project "D:\TTTest\ClassLibrary1.sln" (Rebuild target(s)) -- FAILED.
Build FAILED.
When I looked in file Microsoft.TextTemplating.targets, found out it uses registry keys to find folders who contain dlls:
<PropertyGroup Condition=" $(IncludeDslT4Settings)=='true' ">
<!-- Path to VS\Common7\IDE -->
<!-- Check the 32bit location first ; if that is empty, use the 64bit location. -->
<VsIdePath>$(Registry:HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0#InstallDir)</VsIdePath>
<VsIdePath Condition=" $(VsIdePath) == ''" >$(Registry:HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\14.0#InstallDir)</VsIdePath>
<!-- Set the default location for the Dsl Designer install. -->
<DslDesignerInstallPath Condition=" $(DslDesignerInstallPath)=='' ">$(VsIdePath)Extensions\Microsoft\DSL SDK\Dsl Designer\$(VisualStudioVersion)\</DslDesignerInstallPath>
<!-- Add the standard DSL templates folder -->
<IncludeFolders>$(IncludeFolders);$(DslDesignerInstallPath)TextTemplates\</IncludeFolders>
So I have to install Microsoft Visual Studio 2015 SDK and Microsoft Visual Studio 2015 Visualization & Modeling SDK on build server to registry DLLs.
However, Starting in Visual Studio 2015, you do not install the Visual Studio SDK from the download center. It is included as an optional feature in Visual Studio setup. So we could not install Visual Studio SDK without installing Visual Studio. see Visual Studio SDK for detail info.
Besides, Daniel's has a blog about How to transform T4 templates on build without installing a Visual Studio SDK, you can check if that give any helps.
The problem seemed to be that .NET could not find the assembly Microsoft.VisualStudio.TextTemplating.14.0.dll.
So instead of keeping everything in separate folders as Visual Studio installs them, I took the following files:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating
Microsoft.VisualStudio.TextTemplating.Sdk.Host.14.0.dll
Microsoft.TextTemplating.Build.Tasks.dll
Microsoft.TextTemplating.targets
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0
Microsoft.VisualStudio.TextTemplating.14.0.dll
Microsoft.VisualStudio.TextTemplating.Interfaces.14.0.dll (several files)
Microsoft.VisualStudio.TextTemplating.VSHost.14.0.dll
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PublicAssemblies\
Microsoft.VisualStudio.TextTemplating.Modeling.14.0.dll
And copied them all into the MSBuild task directory:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating
After doing this, .NET was able to find the assemblies it needed and transformed the templates.
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
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.
I am using:
VS Community 2015 edition, Xamarin v4.2, Xamarin.Android v7
It Shows:
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(283,2): error MSB4018: The "GetPrimaryCpuAbi" task failed unexpectedly.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(283,2): error MSB4018: System.TypeLoadException: Could not load type 'Xamarin.Android.Tasks.MSBuildExtensions' from assembly 'Xamarin.Android.Build.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(283,2): error MSB4018: at Xamarin.Android.Tasks.GetPrimaryCpuAbi.Execute()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(283,2): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(283,2): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Please Help
All you need to do is clean your Xamarin project. menu Build > Clean all