Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Packages are missing

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

  1. I do not have .nuget folder in my solutions.
  2. 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.
  3. I tried removing the project from TFS and it didn't fix it.
  4. Along with the above error, all the references in the project have yellow warning signs and say they are missing.
  5. 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.
  6. 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.
like image 774
Ques Tion Avatar asked Aug 27 '15 16:08

Ques Tion


People also ask

Where are my NuGet packages?

The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder.

How do I reinstall NuGet package?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.


1 Answers

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> 
like image 86
DKR Avatar answered Sep 18 '22 10:09

DKR