visual-studio - 错误MSB4062 : The "Xamarin.Forms.Build.Tasks.GetTasksAbi" task could not be loaded from the assembly

标签 visual-studio xamarin xamarin.forms nuget

将软件包“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.

该错误指向文件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>

XamlGTask的下划线带有警告,指出:
Task 'XamlGTask' is not defined

到目前为止,我所做的是清理整个解决方案,删除obj/bin文件夹以及从“程序包管理器设置”中清除“所有Nuget缓存”,但它们都无济于事。

最佳答案

error MSB4062: The “Xamarin.Forms.Build.Tasks.GetTasksAbi” task could not be loaded from the assembly



要解决此问题,您绝对应该确保所有项目都引用相同版本的软件包Xamarin.Forms

在您的Solution Explorer中,右键单击您的解决方案节点,然后选择Manage NuGet Packages for solution...。选择Consolidate选项卡,然后单击Xamarin.Forms NuGet包,确认所有项目使用相同版本。如果不是,请全部更新为相同版本。

此外,有人说安装.NET Framework 4.7.1将有助于解决此问题,您可以检查是否有帮助。

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

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

希望这可以帮助。

关于visual-studio - 错误MSB4062 : The "Xamarin.Forms.Build.Tasks.GetTasksAbi" task could not be loaded from the assembly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50249343/

相关文章:

c# - ASP.Net - 在 SiteMapPath 中链接网站

c# - 如何从我的应用程序强制停止不同的 Android 服务?

android - 如何调试仅在 Release模式下崩溃的 Android 应用程序

asp.net-mvc - 与 Microsoft HTTP 客户端库 v2.1.10 NuGet 更新相关的问题

visual-studio - TFS 在 Visual Studio 2008 启动期间无法加载 "Package Load Failure"

c# - 当前上下文中不存在名称 'InitializeComponent'(c#,xamarin)

xamarin - Xamarin 表单中的占位符文本对齐方式

xamarin - 如何将参数传递给命令

xaml - 所有标签的自定义字体 Xamarin Forms

c# - 在 Visual Studio 中 Hook 构建过程