Solução p/ o erro MSB4018 - Falha inesperada da tarefa "ResolvePackageAssets"

Vinicius Gomes Gonsalves 1 Reputation point
2020-08-22T20:59:47.633+00:00

Erro MSB4018 Falha inesperada da tarefa "ResolvePackageAssets".
NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder 'D:\Microsoft\Xamarin\NuGet\'.
em NuGet.Packaging.FallbackPackagePathResolver..ctor(String userPackageFolder, IEnumerable1 fallbackPackageFolders) em Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(IEnumerable1 packageFolders)
em Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(LockFile lockFile)
em Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter..ctor(ResolvePackageAssets task)
em Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash)
em Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task)
em Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
em Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
em Microsoft.NET.Build.Tasks.TaskBase.Execute()
em Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
em Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() ConsoleApp1 C:\Program Files\dotnet\sdk\3.1.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 241

Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,002 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Dylan Zhu-MSFT 6,421 Reputation points
    2020-08-25T09:33:54.237+00:00

    Hi ViniciusGomesGonsalves,

    Do you install VS2019 with Xamarin workload? The Xamarin workload will place a Xamarin.Offline.config file in C:\Program Files (x86)\NuGet\Config\ which sets C:\Microsoft\Xamarin\NuGet\ as one fallbackPackageFolders. Its content would look like this pic:

    20175-untitled.png

    The build/restore process would check the existance of this folder C:\Microsoft\Xamarin\NuGet\ and throw the error message above if the folder is not found.
    Here're two directions to resolve the issue depending on your scenario:

    1. If you're not developing Xamarin, just feel free to delete the unnecessary Xamarin.Offline.config file.
    2. And if you're developing Xamarin, you can choose to create the missing folder manually or modify the Xamarin.Offline.config file to make it reference correct path of the Xamarin fallback folder.

    Note:

    1. Normally these paths and folders are in C: drive, but your error message indicates it's trying to find the folder in D: drive. This may affect the behavior.
    2. Here's one detailed description about the Xamarin config. link: {https://stackoverflow.com/questions/58419386/vs2017-attempts-to-save-nuget-packages-into-a-xamarin-folder-why/58424383#58424383}

    Best Regards,
    Dylan

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.