Reputation: 91
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
Upvotes: 9
Views: 6735
Reputation: 12853
This can also happen on a build system running multiple builds in parallel where one of these builds clears the NuGet cache.
With unlucky timing, build 1 restores the NuGet packages, build 2 clears the cache, and then build 1 tries to build the projects and fails because the packages have been deleted.
Upvotes: 1
Reputation: 38
The high-level, fast solution that worked for me: Clone the project repository with this error into a different folder and rebuild.
Upvotes: 0
Reputation: 342
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
Upvotes: 10
Reputation: 136
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.
Upvotes: 1