Running the build agent as LocalSystem, and using Nuget 3.3, have tried both with the "native" nuget step and a command line step. In both cases, when I specify verbose output, I see that it is trying to save packages to C:\Windows\system32\config\systemprofile\.nuget\packages\ (Using packages directory: C:\Windows\system32\config\systemprofile\.nuget\packages\). There are no errors reported in the build log. When the Visual Studio solution build step runs it reports multiple errors like "[Csc] CSC error CS0006: Metadata file 'C:\Windows\system32\config\systemprofile\.nuget\packages\Castle.Core\3.3.3\lib\net45\Castle.Core.dll' could not be found" When I look in that location, there is no folder (C:\Windows\system32\config\systemprofile\.nuget is not present). I have tried to manually create that folder and added "Full Control" permissions for "Everyone" but it still does create packages in there and I cannot build the project. I have not found any errors in Windows logs.
The only difference between this project and others that do build is that I am using project.json within the csproj to manage references. If I log onto the build agent under my own account I am able to manually execut nuget restore and msbuild and get a successful build (nuget creates the packages folder in my home directory and msbuild picks up the packages from there).
If I run the build agent under my own account (domain account, admin privileges on build agent machine), the build step succeeds, however, I'd rather not be running under a personal account.
Any ideas where I should be looking for the cause?