The package CacheManager.Core with version 1.0.1 could not be found in C:\Users\username\.nuget\packages\
. Run a NuGet package restore to download the package.
but my project is in D: drive. all of other packages are fine except error for this package. here is snapshoot of packages.config
<packages>
<package id="CacheManager.Core" version="1.0.1" targetFramework="net462" />
<package id="Castle.Core" version="3.3.3" targetFramework="net462" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net462" />...
Actually, the packages are in both mentioned C:\Users\username.nuget\packages\ and in project file location
Restore packages manually using Visual StudioEnable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.
Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.
This project references NuGet package (s) that are missing on this computer. Use NuGet Package Restore to download them. The missing file is {name}. This error occurs when you attempt to build a project that contains references to one or more NuGet packages, but those packages are not presently installed on the computer or in the project.
If you're using Visual Studio, first enable package restore as follows. Otherwise continue to the sections that follow. Select the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore.
This error occurs when you attempt to build a project that contains references to one or more NuGet packages, but those packages are not presently installed on the computer or in the project.
Assets file '<path>\project.assets.json' not found. Run a NuGet package restore to generate this file. The project.assets.json file maintains a project's dependency graph when using the PackageReference management format, which is used to make sure that all necessary packages are installed on the computer.
In our cases following files were created:
obj/LcWebServerExtension.csproj.nuget.cache
obj/LcWebServerExtension.csproj.nuget.g.props
obj/LcWebServerExtension.csproj.nuget.g.targets
obj/project.assets.json
The .g.props file just listed the C:\Users\...
directory, no other of the properly configured directories.
You need two steps to solve the problem:
Set back ToolsVersion of .csproj file from "15" to "12". Right appearance:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import ...
Manually delete obj/
folder, then rebuild
I got the same error when building a project in vs2019 although the package name and user profile were differnt from yours.
It happened to me that I had worked on a project under a profile userA, which was deleted later on. Therefore, it popped up an error when I built the project under a profile userB:
"The package EntityFramework with version 6.1.3 could not be found in C:\Users\userA\.nuget\packages. Run a NuGet package restore to download the package."
I tried to resolve the issue in vain by restoring the packages and revising the nuget config. Finally, I deleted the all files generated by VS2019, which were hidden by .gitignore file. And then the issue was resolved after retoring the packages.
I think the error was caused by .dtbcache file located in .vs folder: $\Solution\.vs\ProjectName\DesignTimeBuild\.dtbcache.v2
This file stores the nuget package information. It was outdated after I switched to another user profile as the nuget package path was not updated.
At Stack Overflow there is a disscusion about .dtbcache file: What does the .dtbcache file do?
And here is a similiar issue on GitHub: https://github.com/dotnet/project-system/issues/5418
The question was posted almost 2 years ago and it might be already resolved. Yet I am answering in case someone else comes across this issue. Hope my comment would be helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With