• I have used the command
xamarin-component.exe package C:\\cmp\\AndroidComponent\\component
for creating Xamarin component.While building th
We ran into the same issue; you were close to the right answer, and the forums had the correct one.
First lets look at the portion of code that is erroring (Xamarin.Android.Common.targets; in the newer versions of Xamarin this code is much further down):
<Target Name="_GetReferenceAssemblyPaths">
<GetReferenceAssemblyPaths
TargetFrameworkMoniker="$(TargetFrameworkIdentifier),Version=v1.0"
RootPath="$(TargetFrameworkRootPath)">
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_XATargetFrameworkDirectories" />
</GetReferenceAssemblyPaths>
The most important part here is the
$(TargetFrameworkRootPath)
When NuGet is ran via the command line we see that it is using the 64bit MSBuild Executable:
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin\amd64'.
(You correctly identified this yourself above) but just to be clear for anyone following along.
When you use the 64bit version of MSBuild $(TargetFrameworkRootPath)
gets defined as C:\Program Files\Reference Assemblies\Microsoft\Framework
However Xamarin does not install any of the Framework Utilities to that directory; instead everything lives in the x86 version here C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework
When you read online a ton of people get this problem solved by installing Visual Studio 2017; but that is a red-herring it only works because it causes NuGet to use MSBuild 15 which ships with Visual Studio 2017 which apparently is not affected by this bug.
There are a few ways to fix this issue:
$(TargetFrameworkRootPath)
to be C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework
; this can be done however you please, the biggest hammer is to set it as an environment variable in the environment prior to execution. Note this will probably cause a bunch of unintended side-affects if you're not careful.