Skip to content

[BUG]: Access to the path '*.csproj.nuget.g.props' is denied #21908

@LoriBru

Description

@LoriBru

New issue checklist

Task name

DotNetCoreCLI

Task version

2

Issue Description

Hello, I am currently running an Agent on my local VM, the version is 4.268.0.
I am struggling to get the unit test pipeline working for my .NET solution.
The pipeline currenly looks like this (but I tried already many attempts):

trigger: none

pool:
  name: Vs2026

variables:
  solution: '**/*.slnx'
  buildPlatform: 'x64'
  buildConfiguration: 'Release'

steps:
- task: DotNetCoreCLI@2
  displayName: Build solution
  inputs:
    command: 'build'
    projects: '$(solution)'
    arguments: '--configuration $(BuildConfiguration) /p:Platform=$(BuildPlatform)'
- task: DotNetCoreCLI@2
  displayName: 'Run unit tests'
  inputs:
    command: 'test'
    projects: '**/tests/*/*.csproj'

I get the following error when I try to run it:

##[debug]8822 results
##[debug]found 8822 paths
##[debug]applying include pattern
##[debug]adjustedPattern: 'C:\agents\VS2026\_work\3\s\**/tests/*/*.csproj'
##[debug]19 matches
##[debug]19 final results
##[debug]which 'C:\Program Files\dotnet\dotnet.exe'
##[debug]found: 'C:\Program Files\dotnet\dotnet.exe'
##[debug]C:\Program Files\dotnet\dotnet.exe arg: test
##[debug]C:\Program Files\dotnet\dotnet.exe arg: C:\agents\VS2026\_work\3\s\tests\Testing.Core.Authentication\Testing.Core.Authentication.csproj
##[debug]C:\Program Files\dotnet\dotnet.exe arg:  --logger trx --results-directory "C:\agents\VS2026\_work\_temp" 
##[debug]exec tool: C:\Program Files\dotnet\dotnet.exe
##[debug]arguments:
##[debug]   test
##[debug]   C:\agents\VS2026\_work\3\s\tests\Testing.Core.Authentication\Testing.Core.Authentication.csproj
##[debug]   --logger
##[debug]   trx
##[debug]   --results-directory
##[debug]   C:\agents\VS2026\_work\_temp
"C:\Program Files\dotnet\dotnet.exe" test C:\agents\VS2026\_work\3\s\tests\Testing.Core.Authentication\Testing.Core.Authentication.csproj --logger trx --results-directory C:\agents\VS2026\_work\_temp
Specifying a project for 'dotnet test' should be via '--project'.
##[debug]Exit code 1 received from tool 'C:\Program Files\dotnet\dotnet.exe'
##[debug]STDIO streams have closed for tool 'C:\Program Files\dotnet\dotnet.exe'
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
##[debug]Processed: ##vso[task.issue type=error;]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1

...

And so on for all my unit tests projects.

If I remote login into my VM, I execute dotnet test and I get the following error:

PS C:\agents\VS2026\_work\3\s\tests\Testing.Core.Authentication> dotnet run --project=Testing.Core.Authentication.csproj
C:\Program Files\dotnet\sdk\10.0.103\NuGet.targets(196,5): error Access to the path 'C:\agents\VS2026\_work\3\s\src\Core.Contracts\obj\Core.Contracts.csproj.nuget.g.props' is denied.
The build failed. Fix the build errors and run again.

But then if I run my cmd as Administrator it works just fine.
Can you help me with this issue? Thanks.

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

Azure DevOps Server (Please specify exact version in the textbox below)

Azure DevOps Server Version (if applicable)

Azure DevOps Server 2022.2

Operation system

Windows Server 2025

Relevant log output

##[debug]8822 results
##[debug]found 8822 paths
##[debug]applying include pattern
##[debug]adjustedPattern: 'C:\agents\VS2026\_work\3\s\**/tests/*/*.csproj'
##[debug]19 matches
##[debug]19 final results
##[debug]which 'C:\Program Files\dotnet\dotnet.exe'
##[debug]found: 'C:\Program Files\dotnet\dotnet.exe'
##[debug]C:\Program Files\dotnet\dotnet.exe arg: test
##[debug]C:\Program Files\dotnet\dotnet.exe arg: C:\agents\VS2026\_work\3\s\tests\Testing.Core.Authentication\Testing.Core.Authentication.csproj
##[debug]C:\Program Files\dotnet\dotnet.exe arg:  --logger trx --results-directory "C:\agents\VS2026\_work\_temp" 
##[debug]exec tool: C:\Program Files\dotnet\dotnet.exe
##[debug]arguments:
##[debug]   test
##[debug]   C:\agents\VS2026\_work\3\s\tests\Testing.Core.Authentication\Testing.Core.Authentication.csproj
##[debug]   --logger
##[debug]   trx
##[debug]   --results-directory
##[debug]   C:\agents\VS2026\_work\_temp
"C:\Program Files\dotnet\dotnet.exe" test C:\agents\VS2026\_work\3\s\tests\Testing.Core.Authentication\Testing.Core.Authentication.csproj --logger trx --results-directory C:\agents\VS2026\_work\_temp
Specifying a project for 'dotnet test' should be via '--project'.
##[debug]Exit code 1 received from tool 'C:\Program Files\dotnet\dotnet.exe'
##[debug]STDIO streams have closed for tool 'C:\Program Files\dotnet\dotnet.exe'
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
##[debug]Processed: ##vso[task.issue type=error;]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1

Full task logs with system.debug enabled

Details
 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions