Incidentally, I have solved the environment problem in a PowerShell script I'm using to configure a freshly started virtual machine: https://gist.github.com/jberezanski/01319436ca0c78a60120 (which contains workarounds for other issues as well). The key is to always stay in PowerShell (invoke Chocolatey using chocolatey.ps1 instead of cmd wrappers), that way the environment can be controlled and corrected when needed. I'm currently in the process of submitting most of the patches implemented in that script as pull requests.

If your TeamCity build script is (or can be) written in PowerShell, you can use a similar technique to ensure Chocolatey PATH additions are visible immediately after installation. In that case the Exec command in build.ps1 can be simplified to ````nuget pack &quot;%(NuspecFiles.FullPath)&quot; -NoPackageAnalysis````.