Ayal
Ayal

Reputation: 533

Error: The build restored NuGet packages. Build the project again to include these packages in the build. For more information

When I build my project for the first time the build succeeds, but when I Publish the project, the build fails and I get several errors that say:

The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see the below link http://www.postsharp.net/links/nuget-restore.

What does this mean? And what can I do?

Upvotes: 45

Views: 25599

Answers (4)

Olivier MATROT
Olivier MATROT

Reputation: 35

For those of you that are migrating old .NET 4.7.X project to .NET Core, this error may be thrown because you have a reference to the Bcl.Build package in your project file, like the following :

  <Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
    <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="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=317567." HelpKeyword="BCLBUILD2001" />
    <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
  </Target>

Removing this Target node entirely solved the problem for me.

Upvotes: 1

Mr. Flibble
Mr. Flibble

Reputation: 27023

Cleaning the solution before rebuild fixed this for me.

Upvotes: 20

Govind
Govind

Reputation: 59

For me, issue with one of the project where I had duplicates for nuget with different version in packages.config which stopped the project in downloading packages from nuget.org. Removing duplicate entry in packages.config worked like a charm.

Upvotes: 0

Avi
Avi

Reputation: 1201

Try run Build Solution and restart visual studio. It did the job for me.

Upvotes: 90

Related Questions