Not able to create a Xamarin-component for android Source code

前端 未结 1 751
野的像风
野的像风 2021-01-26 07:46

• I have used the command

xamarin-component.exe package C:\\cmp\\AndroidComponent\\component 

for creating Xamarin component.While building th

相关标签:
1条回答
  • 2021-01-26 08:43

    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:

    1. Tell NuGet to use the x86 MSBuild when you Restore using the optional -MSBuildPath argument as described here How Can I Tell NuGet What MSBuild Executable to Use?
    2. Upgrade to Visual Studio 2017 to get MSBuild 15
    3. Define $(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. <- DON'T DO THIS, Even as suggested in the forms.
    0 讨论(0)
提交回复
热议问题