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

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

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:

1 2 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:

1 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

Updated on April 11, 2025

Still need help?

The Atlassian Community is here for you.