MSB4018 解决包资产任务意外失败,同时尝试学习如何在 C# 中使用堆栈

MSB4018 Resolve Package Assets task failed unexpectedly, while trying to learn how to use stacks in c#

您好,感谢您的提前帮助

上面的错误代码是在尝试学习堆栈时出现的。 我在 windows 11,我在网上看到的大多数其他问题都使用 macs,并指出 mac 版本的问题,据我所知他们不能在这里帮助我。

到目前为止我已经尝试过:

以及非常长的完整错误消息:

Severity    Code    Description Project File    Line    Suppression State
Error   MSB4018 The "ResolvePackageAssets" task failed unexpectedly.
NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder 'D:\Coding\Components-tools-SDK\NuGetPackages'.
   at NuGet.Packaging.FallbackPackagePathResolver..ctor(String userPackageFolder, IEnumerable`1 fallbackPackageFolders)
   at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(IEnumerable`1 packageFolders)
   at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(LockFile lockFile)
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter..ctor(ResolvePackageAssets task)
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash)
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task)
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() pushpopstacks   C:\Program Files\dotnet\sdk.0.406\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets    241 

再次感谢任何帮助或建议。

参见this Page

解决方法是Manually added the empty folder C:\Microsoft\Xamarin\Nuget and recompiled the VS it should work.