NuGet restore fails with error MSB1009: Project file does not exist when running Bamboo agent service as LOCAL SYSTEM

Still need help?

The Atlassian Community is here for you.

Ask the community

Problem

NuGet restore during a MSBuild Task fails with error MSB1009: Project file does not exist when running Bamboo agent service as the LOCAL SYSTEM account. The following appears in the build log:

build	13-Jan-2020 15:07:00	MSBUILD : error MSB1009: Project file does not exist. [C:\Bamboo\bamboo-agent-home\xml-data\build-dir\PROJ-PLAN-JOB1\BUILD_msbuild.proj]
build	13-Jan-2020 15:07:00	  Switch: C:\windows\system32\config\systemprofile\AppData\Local\Temp\NuGetScratch\dtuk4fmu.hcu.nugetinputs.targets

Diagnosis

Environment

  • Bamboo agent running as a Windows Service under the LOCAL SYSTEM account.

Cause

NuGet is unable to write to C:\windows\system32\config\systemprofile\AppData\Local\Temp while running under this context

Workaround

Option 1: Override the TMP and TEMP directory environment variables values to a different location

Configure the MSBuild task at Plan Configuration >> Tasks >> MSBuild and set the Environment Variables field to override the values. Example:

TMP="C:\Bamboo\bamboo-agent-home\temp" TEMP="C:\Bamboo\bamboo-agent-home\temp"
Option 2: Configure the Bamboo agent Windows Service to run under a local user account context
  1. Start >> Run >> services.msc
  2. Find the Atlassian Bamboo remote agent service
  3. Right click >> Properties >> Log On
  4. Configure the service to run as a local user account of your choosing
  5. Ensure this local user account as full ownership over the $BAMBOO_AGENT_HOME directory
  6. Restart the agent



DescriptionNuGet restore during a MSBuild Task fails with error MSB1009: Project file does not exist when running Bamboo agent service as the LOCAL SYSTEM account.
ProductBamboo

Last modified on Jan 23, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.