NuGet Error NU5037: The package is missing the required nuspec file…

image of missing nuspec file

Author: Richard Boroczky

Ah, the dreaded package is missing the required nuspec file> build error. This happens so infrequently that when it does I don`t remember what I did to fix it last time. Well today I was testing my custom NuGet packages in an ASP.NET Core application where I had refactored out the authentication pieces into these reusable packages when I encountered this error. This time I decided to document it and add it to my blog entries for the next time this occurs for us.

I tried the usual steps of cleaning and rebuilding the solution, but that did not work. I deleted the obj and bin folders and rebuilt, but that also did not work. Then I tried the dotnet restore command and rebuilt, but still got the same error. Then I thought about it for a bit and remembered NuGet has local stores and figured that I should try clearing them out. So I did this, performed a restore and low and behold that was the key giving me a successful build; the NuGet Error NU5037 was resolved.

If you are using Visual Studio, then you are in luck since clearing out NuGet storage is simple. You open the Options menu item and filter out using the test NuGet. In the General section, there is a button labeled, Clear All NuGet Storage, so click it. Now all you need to do is perform a package restore with a rebuild and this issue should now be resolved! Happy Coding!

Hint: For those who prefer the command line: dotnet nuget locals all --clear>

image of Visual Studio Option Menu For NuGet