OctoPack help in TFS


I’m getting the following error in TFS:

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.

Building again doesn’t help - exactly the same thing no matter how many times I build.

The last part of the error does give something helpful - The “You may also need to make sure that your build server does not delete packages prior to each build.” - If I change the “Clean Workspace” option in the build definition process from “All” to “None”, then it does indeed start to work correctly.

However I do want the Clean Workspace set to All ideally.

So, how do I get this working with Clean Workspace set to all?

We don’t have anything within the /packages folder checked into TFS, so I don’t want to have to start that because it’s a large enterprise scale application and it’s breaking the pattern that we’re using for every other package.

Thank you

We solved this by creating a build.proj file that builds the solution, and having the TFS build build that, instead of building the SLN directly.
See http://docs.nuget.org/consume/package-restore/team-build


Thanks for that link, I did come across that but I didn’t pursue it for two reasons:

  1. We are using TFS 2013 which appears to be out of scope according to the “Applies to:” box at the top of the article.

  2. It was my understanding that this was the solution for if the packages were not being restored, in my instance, the packages are being restored. I get an error stating they are restored but there is no .targets file.

However if you’ve tried this and it’s fixed for you, then I’ll give it a go later today and report back.


Hi Ben,

Thanks for reaching out. The link that rpresser provided should work for your TFS 2013 as well. Please give it a try and let me know how it goes



Hi Dalmiro

What part of the link are we talking about, creating a new build.proj and setting this to be the build target?

As far as I can tell, this particular solution is to make the build server to a package restore prior to building, is that correct?

I don’t think I need to do that, the package restore is already happening. I think that TFS 2013 is out of scope of that article, it certainly seems so based on the information right at the top.


Hi Ben,

Sorry for the delay here. Yes that setting is there to make the restore happen prior to building. This should work on your version of TFS. Would you be able to send me a full build log to check what might be going on?