Hi @Wang, Jesse,
Welcome to Microsoft Q&A!
Are you using packages.config or PackageReference format?
When using the PackageReference management format, this error might be a leftover from a packages.config to PackageReference migration and needs to be manually removed from the project file.
When using packages.config, the error means that the package is not installed in the packages folder at the solution root.
If NuGet Package Restore doesn’t work, please delete the packages folder (when using packages.config) or the obj/project.assets.json file (when using PackageReference) and run restore again. If the error still persists, use nuget locals all -clear or dotnet nuget locals all --clear from the command line to clear the global-packages and cache folders.
Besides, you can backup and remove the following EnsureNuGetPackageBuildImports section from your .csproj file, then rebuild your project:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
---
</Target>
Sincerely,
Anna
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.