I'm building a project in TeamCity with NuGet package restore enabled.
I have two build steps:
One of the projects has the log4net-package from the official feed installed. (But don't get to hung up on which package)
My problem is when TeamCity runs the first step, it fails in the nuget-installer step with the message: Unable to find version '2.0.3' of package 'log4net'.
So after doing my best to find any errors in the solution, I try to:
[Edit] Concerning the 3. step, MSBuild should ideally, as John H. points out, be able to rebuild the packages, so I shouldn`t need a NuGet Installer step. The error when I try to build the solution without the nuget installer step has something to do with the OctoPack-package I have installed:
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
Then it succeeds.. Why?
Does anyone have some insight on my issue?
Some more background:
I assume this has something to do with the octopus deploy package. I have the octopus deploy plugin installed on the teamcity server and I´ve ticked the Run OctoPack checkbox in the MSBuild step.
I have tried to uninstall the octopack package and reinstall without any success.
Can it be that NuGet-package restore on the MSBuild-step combined with the octopus plugin is causing my problems?
[Partial resolution] I'm still uncertain why I got the error on the log4net-package. I was running NuGet installer as the first step in my automatic build, which in the end proved to be the correct thing to do due to the nature of the build.
I admit I don't (always) read the "what's new" when a package is updated. When upgrading Octopack from 2.0.26 to 3.0.19 one of the changes is that you no longer need to check in the .octopack folder. So I could really understand why the build could not find the targets-file, when it was checked in.
Now I've:
and the build is running fine.
Thanks for all help! I'm a better educated man now :)
[Removed] irrelevant information
The solution is to run Nuget restore before the restore step that is run by MSBuild.
The MSBuild step halts if it has to restore packages. Doing the restore before MSBuild runs prevents means it does not have to do a restore. This solution is discussed in this .NET Framework Blog article.
Response from the Octopus Deploy team is here.
The same problem can cause TFS to fail - see RinoTom's answer here. I use Continua CI and have added a command line step to run the Nuget restore prior to the MSBuild step.