Reputation: 1300
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:
Tools -> Options -> Nuget Package Manger -> General
and checked both options.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.
%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)
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)
.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:
Upvotes: 0
Views: 2077
Reputation: 76700
Install failed. Rolling back... Package "A" does not exist in the project. Package "A" already exist in the folder.
That because the "Packages" folder under git version control. You should use the .gitignore file to have Git ignore the contents of the packages folder.
For the detail info, you can refer to the Omitting NuGet packages in source control systems.
Hope this can help you.
Upvotes: 1