OctoPack cannot run because NuGet packages were restored prior to the build

I’m using Octopack 3.0.19 with Nuget package restore and am getting the following error during the build:

D:\CI_WS\Ws\634\Source\BitBucket-Infrastructure \Code\WebAdminUI\Infrastructure.AdminUI.csproj(551,5): error : OctoPack cannot be run because NuGet packages were restored prior to the build running, and the targets file was unavailable when the build started. Please build the project again to include these packages in the build. You may also need to make sure that your build server does not delete packages prior to each build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." status=error

Any ideas?

Related Stack Overflow question here

Hi Sean,

This error happened because when MSBuild ran on the solution, OctoPack.targets was missing (NuGet package restore had not yet run). Since the targets couldn’t be loaded, OctoPack can’t work.

The solution is to perform a NuGet restore prior to building your packages. For TeamCity, you can use the NuGet Installer runner. For TFS, you can use the information here:

We have some more details on the changes in OctoPack 3.0 here:

Hope that helps,

Paul

Perfect, thank you Paul.