错误MSB4062:无法从程序集加载"Xamarin.Forms.Build.Tasks.GetTasksAbi"任务

Vah*_*hir 6 visual-studio nuget xamarin xamarin.forms

将软件包"Xamarin.Forms"和"Xamarin.Forms.Maps"更新到最新版本即"3.0.0.446417"后,项目将不再构建,我收到此错误:

    C:\Users\[MyUser]\.nuget\packages\xamarin.forms\3.0.0.446417\build\netstandard2.0\Xamarin.Forms.targets(35,3):
error MSB4062: The "Xamarin.Forms.Build.Tasks.GetTasksAbi" task could not be loaded from the assembly
C:\Users\[MyUser]\.nuget\packages\xamarin.forms\3.0.0.446417\build\netstandard2.0\Xamarin.Forms.Build.Tasks.dll.
Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
Run Code Online (Sandbox Code Playgroud)

该错误指的是文件Xamarin.Forms.Targets的这个位置:

<XamlGTask
    XamlFiles="@(EmbeddedResource)" Condition="'%(Extension)' == '.xaml' AND '$(DefaultLanguageSourceExtension)' == '.cs'"
    Language = "$(Language)"
    AssemblyName = "$(AssemblyName)"
    OutputPath = "$(IntermediateOutputPath)">
    <Output ItemName="FilesWrite" TaskParameter="GeneratedCodeFiles" />
    <Output ItemName="Compile" TaskParameter="GeneratedCodeFiles" />
</XamlGTask>
Run Code Online (Sandbox Code Playgroud)

XamlGTask的下划线标有警告:

Task 'XamlGTask' is not defined
Run Code Online (Sandbox Code Playgroud)

到目前为止我所做的是清理整个解决方案,删除obj/bin文件夹,还清除包管理器设置中的所有Nuget缓存,但它们都没有帮助.

Leo*_*SFT 10

错误MSB4062:无法从程序集加载"Xamarin.Forms.Build.Tasks.GetTasksAbi"任务

要解决此问题,您一定要确保所有项目都引用相同版本的包Xamarin.Forms.

Solution Explorer右键单击解决方案节点并选择Manage NuGet Packages for solution....选择Consolidate选项卡并单击Xamarin.FormsNuGet包,确认所有项目使用相同的版本.如果没有,请将所有版本更新为相同版本.

此外,有人说安装.NET Framework 4.7.1有助于解决这个问题,你可以检查它是否有帮助.

认证:https://forums.xamarin.com/discussion/comment/324869#Comment_324869

注意:如果您无法成功安装.net framework 4.7.1,请尝试将Windows 10更新到最新版本.谢谢@Vahid.

希望这可以帮助.

  • 我的所有项目都有相同版本的软件包,即合并部分中没有列出任何软件包.我所有的软件包都从这里接受了@DanSiegel的建议并下载了.NETFramework 4.7.1但是由于安装失败,经过进一步搜索后我不得不将我的Windows 10更新到最新版本,现在我不再收到该错误并且我的项目构建成功. (2认同)