NuGet Packages are missing
Solution 1
I had the same error (missing exactly the same package) today. I also created a MVC + Web API project.
It happened because I moved the app files (including the .csproj) file to another location. I manually updated the .sln file but all packages dependencies are now (Visual Studio 2015) stored in .csproj file.
Editing the .csproj file and correcting the relative path to the solution folder (which contains the packages folder) solved the problem for me.
Solution 2
I solved my issue by removing this code from .csproj
file:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
Solution 3
BEWARE - this updates packages for the entire solution not just the project.
If you have one more missing nuget package that giving your error while building your solution use following command using Nuget Command Console from Tools > Nuget Package Manager > Package Manager Console. It will reinstall your all current packages.
Update-Package –reinstall
Update:
You can pass specific project name as a parameter.
Update-Package –reinstall -ProjectName SampleApp
Solution 4
I had this exact frustrating message. What finally worked for me was deleting all files and folders inside /packages and letting VS re-fetch everything the next build.
Solution 5
this way solved my error : To open .csproj file for update in Visual Studio 2015+ Solution Explorer:
Right-click project name -> Unload Project
Right-click project name -> Edit .csproj
Remove the following lines :
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
<Error Condition="!Exists('packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
Right-click project name -> Reload Project
Finally Build your solution.
Ques Tion
Updated on January 29, 2022Comments
-
Ques Tion over 2 years
I searched this problem but none of the solutions worked. I have Visual Studio Professional 2015 installed and I am using TFS. My NuGet version is 3.1.6. This problem is happening only in my C# Web API/MVC project.
I am getting the below error:
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props
- I do not have .nuget folder in my solutions.
- I have a packages folder in the solution and when I delete it, it seems like NuGet does rebuild the dependencies but the project still has the above error.
- I tried removing the project from TFS and it didn't fix it.
- Along with the above error, all the references in the project have yellow warning signs and say they are missing.
- When I checked the NuGet Package Manager for the project, everything that is "missing" has a green tick next to it, including Microsoft.Net.Compilers.
- I tried adding a new Web API/MVC project and it faced a similar problem where most references such as Owin were "missing" with the yellow warning sign.
-
Justin Wignall over 8 yearsCopying the Microsoft.Net.Compilers... folder from the old packages folder to the new packages location after a move if it is missing may be a final step required.
-
Vitor Canova over 8 yearsI did a right click on the Solution and
Restore Nuget Packages
. -
Patrick Borkowicz over 8 yearsThis worked for me. The error popped up after for me after pushing changes through git on one system and pulling them on another. Maybe my .gitignore is not properly configured for nuget packages.
-
SO User about 8 yearsBeware ... this updates packages for the entire solution not just the project.
-
ISAE about 8 yearswhat did work for me in the end was to edit only the line at the end of the file, but not at the top
-
SpoiledTechie.com about 8 yearsI just removed that ONE package from my computer and it worked.
-
Levi Fuller about 8 yearsAccepted answer would not work since I am referencing the project in multiple separate solutions. This was the only fix. Commented it out and it worked like a a charm.
-
Ziggler about 8 yearsI donot have any Restore Nuget Package when I right click on solution.... I am using VS 2013..
-
Andrew Jens over 7 yearsI also got the error when physically moving a project to a different location in the Visual Studio solution. None of the solutions on this page worked, so I made a copy of the project (on the file system) and completely removed all reference to the original project in VS. I then recreated the project and copied the bits and pieces into it (from the copy I made). Laborious, but it worked.
-
Nick Alexander over 7 yearsThis worked for me. NuGet kept complaining about missing packages, but Visual Studio would not auto-resolve. It took a couple minutes to run completely, but this command fixed my problem.
-
Maarten Kieft over 7 yearsI also removed these lines, but I'm more wondering, why are those lines there. Its not than my code won't run. Also why are those nugets so special that they must be included? Why was a normal broken reference not enough??
-
HeyZiko over 7 yearsI could be wrong, but I believe this is "swatting the fly with the hammer". If, for whatever reason, the published location loses any other required nuget package, it will not error, giving you a false positive (i.e. deployment succeeds, but system fails). Not a fan, but I'm not going to downvote it because there are aspects of nuget I'm still not familiar with.
-
Ryan Peters about 7 yearsThis also worked for me. Odd that the error message was hard-coded in the proj file itself ...
-
Tom McDonald about 7 yearsConfirmed this issue still exists in VS 2017. I migrated a project from visual studio 2015 to 2017 and got this error message upon first compile in 2017. This fixed the bug.
-
Nirman about 7 yearsI also had the same issue after moving project from one location to another. Fixing path of the packages in the ".csproj" file fixed the issue.
-
Nicow about 7 yearsWhy delete functionality, risk your project breaking etc by doing this? As @HeyZiko points out this can lead to problems later on. I could just do what the error states "Enable package restore". See my answer somewhere on this page...
-
Jain Prince almost 7 yearsThanks!! I too faced similar situation, and 'Enable NuGet Package Restore' worked.
-
Miłosz Wieczorek almost 7 yearsInstead of doing it manually, I suggest doing it via Package Manager console: 'update-package -ProjectName {ProjectName} -Reinstall' . This works like a charm :)
-
Miłosz Wieczorek almost 7 yearsYou can add -ProjectName parameter to make it only for specific project, not entire solution.
-
Dalibor almost 7 yearsIt didn't wok for me, it says "All packages are already installed and there is nothing to restore."
-
Sachin almost 7 yearsI think this is not a good answer, it is something like if any testcase is not passing then comment that and you task is done. But that is not a way.. You must have find the root cause and resolve it, rather than commenting or removing such code..
-
Francisco d'Anconia almost 7 years@MiłoszWieczorek I tried running the command in Package Manager Console and it did not solve the issue. It reloaded all packages, but the references are still not found.
-
alehro almost 7 yearsThis answer didn't help at once but given me right direction. Additionally to <Target Name="EnsureNuGetPackageBuildImports"... there were some excessive <Import Project... nodes. So, general approach is to read your project file xml and get rid of everything not making sense.
-
Sebastian Schumann over 6 yearsI've exactly that problem using VS2017, .Net4.7 and a unit testing project. That project is added to multiple solutions. The automatic restore works but to the wrong place. Replace with
$(SolutionDir)
work but update failes. I asked that here. Do you have any solution found? -
Dan Csharpster over 6 yearsI had this problem because my file path was too long for package Microsoft.CodeDom.Providers.DotNetCompilerPlatform. My fix was to move the entire solution closer to the root C:\. Error message: Install-Package : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters
-
CodeHxr over 6 yearsThis may be "swatting a fly with a hammer", but in my case, my project had ZERO nuget packages (one other project in the solution did, though, if that makes a difference, but that project compiled fine) and the options to "Enable package restore" were, in fact, checked.
-
codecypher over 6 yearsRather than delete this entry in .csproj, I edited it to correct the path to the
packages
folder and it worked. -
Zephryl over 6 yearsJust FYI, I upgraded the compiler via nuget and it left these pointed to the old version. So, my fix was to leave the paths along and update the version numbers. The correct paths were at the top in <Import /> tags
-
Richard Moore about 6 yearsDidn't read Rashmi's comment about it updating packages for the entire solution until it was too late. BEWARE
-
rollsch about 6 yearsVS2017 crashed half way through this and it broke everything
-
Umair Anwaar over 5 yearsI just restore whole nudget packages multiple times but problem resolved by removing these line of hard-coded error.
-
Protector one over 5 yearsBut why where these wrong in the first place? Bug in Visual Studio?
-
Matheus Miranda over 5 yearsSaved my day. Thank you
-
willyMon about 5 yearsAfter fixing manually the paths in csproj I removed the section EnsureNuGetPackageBuildImports and it worked perfectly. thanks
-
ZF007 about 5 yearsYou are reporting the traceback error and no answer to the question how its solved (regardless the hint of MS in that error-log). You posted information and the real answer are posted multiple times. Therefore unfortunately low quality answer and thus no answer.
-
AceMark about 5 yearsalso had to make sure that it restores to the right package. check the .csproj using note/Edit *.csproj for the location of the packages folder
-
CyberNinja almost 5 yearsI did this, but i only remove the dot.compiler reference, which we dont really need in production neither on the test env.
-
Károly Ozsvárt almost 5 yearsI had a problem where I moved the project files to the level of the .sln file, and I had to change the "..\packages\etc" references to ".\packages\etc", so it wouldn't climb up one directory.
-
Nick over 4 yearsI removed all the nuget packages from the packages folder, and then tried redownloading all packages at build received a build error. I then just had to reinstall the nuget.org/packages/… package and everything worked perfectly
-
sgrysoft over 4 yearsNo edit is need it, edit the csprog is the evil, is a better idea test to clear the cache of the packages
-
Asiri Dissanayaka almost 4 yearsIn my case I moved .sln and changed paths to .csproj files, then got this error. Correcting the paths in .csprojs worked for me.
-
Andrew Morton over 3 yearsThis also applies when there is a rogue error condition referring to 3.5.0 when it has been updated to 3.7.0.
-
ssmith over 3 yearsJust says "No package updates are available from the current package source for project " and doesn't do anything in my case.
-
ssmith over 3 yearsWorked for me. A bit overkill but other options didn't fix the issue.
-
4e 69 63 6b almost 3 yearsI had this exact same issue - .NET 4.7.2 csproj file was moved inside of a "src" subfolder so the references to "packages" were off by one directory. This also corrected a separate issue that prevented me from installing various NuGet packages. Specifically Autofac v6.2.0, which reported "Failed to add reference. The package 'System.Numerics.Vectors' tried to add a framework reference to 'System.Numerics' which was not found in the GAC. This is possibly a bug in the package."
-
CervEd over 2 yearsThose conditions are checking that packages exists in two places. (a bit odd, one is enough). A better alternative to deleting them is to fix the path to point to the actual packages folder. It's relative. Your package folder is likely
..\..\packages
or..\..\..\packages
or similar. -
Eric Aya over 2 years