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