I cloned project from Gitub. My solution has 6 projects and every project has packages.config file (which has listing of packages along with their versions) but these packages are not restored.
Methods I already tried to restore nuget packages:
- In Visual Studio:
Tools -> Options -> Nuget Package Manger -> General
and checked both options. - Write Following Code in
web.config
file:
<packageRestore>
<!-- The 'enabled' key is True when the "Allow NuGet to download missing packages" checkbox is set.
Clearing the box sets this to False, disabling command-line, automatic, and MSBuild-Integrated restore. -->
<add key="enabled" value="True" />
</packageRestore>
This restored packages for that project, but other projects don't have web.config file.
- Added following code in
%AppData%\NuGet\NuGet.Config
:
<configuration>
<packageRestore>
<!-- The 'automatic' key is set to True when the "Automatically check for missing packages during
build in Visual Studio" checkbox is set. Clearing the box sets this to False and disables
automatic restore. -->
<add key="automatic" value="True" />
</packageRestore>
</configuration>
(source)
- Run this command in Package Manager Console:
Update-Package –reinstall
It said this for all the packages:
Package 'Abp.2.1.2' already exists in project 'TempABP5.Migrator'
Successfully installed 'Abp 2.1.2' to TempABP5.Migrator
Created a
NuGet.Config
file next to your.sln
file, containing:<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> <add key="aspnetwebstacknightlyrelease" value="https://www.myget.org/f/aspnetwebstacknightlyrelease/" /> </packageSources> </configuration>
(source)
- Tested by removing following 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>
(source)
But still I cannot restore packages and project fails to build. How can I restore missing packages?
Updated:
Below image contains the screen shot of project and errors:
I deleted all data in bin/obj folders and then clean solution and then build but same errors..
Then I again run the command Update-Package –reinstall
to make sure that packages already exists and the result is: