Skip to content

Access to the path is denied - MacOS 11 - Net6.0 #22929

Open
@JamieHWK

Description

@JamieHWK

Describe the bug

When trying to perform a build of a dotnet project, it fails with Access to path is denied exception. The build should succeed.

File permissions look correct and the copy step can be performed manually successfully.

On rerun of the build command, the build succeeds. It should work first time. In some situations in other more complex repos, it fails consistently. The simple scenario is detailed below.

To Reproduce

jamie.hopper@<machineID> Misc % dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.6
 OS Platform: Darwin
 RID:         osx.11.0-x64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.100/

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  5.0.403 [/usr/local/share/dotnet/sdk]
  6.0.100 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
jamie.hopper@<machineID> Misc % dotnet new console -n AccessDeniedDemo  
The template "Console App" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /Users/jamie.hopper/Src/Misc/AccessDeniedDemo/AccessDeniedDemo.csproj...
  Determining projects to restore...
  Restored /Users/jamie.hopper/Src/Misc/AccessDeniedDemo/AccessDeniedDemo.csproj (in 81 ms).
Restore succeeded.

jamie.hopper@<machineID> Misc % cd AccessDeniedDemo 
jamie.hopper@<machineID> AccessDeniedDemo % dotnet build  
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
/usr/local/share/dotnet/sdk/6.0.100/Microsoft.Common.CurrentVersion.targets(5100,5): error MSB3021: Unable to copy file "/Users/jamie.hopper/Src/Misc/AccessDeniedDemo/obj/Debug/net6.0/apphost" to "bin/Debug/net6.0/AccessDeniedDemo". Access to the path is denied. [/Users/jamie.hopper/Src/Misc/AccessDeniedDemo/AccessDeniedDemo.csproj]

Build FAILED.

/usr/local/share/dotnet/sdk/6.0.100/Microsoft.Common.CurrentVersion.targets(5100,5): error MSB3021: Unable to copy file "/Users/jamie.hopper/Src/Misc/AccessDeniedDemo/obj/Debug/net6.0/apphost" to "bin/Debug/net6.0/AccessDeniedDemo". Access to the path is denied. [/Users/jamie.hopper/Src/Misc/AccessDeniedDemo/AccessDeniedDemo.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.83

And the output from the file referenced in the exception:

jamie.hopper@<machineID> AccessDeniedDemo % ls -lh obj/Debug/net6.0        
total 504
-rw-r--r--  1 jamie.hopper  staff   959B  7 Dec 10:21 AccessDeniedDemo.AssemblyInfo.cs
-rw-r--r--  1 jamie.hopper  staff    41B  7 Dec 10:21 AccessDeniedDemo.AssemblyInfoInputs.cache
-rw-r--r--  1 jamie.hopper  staff   443B  7 Dec 10:21 AccessDeniedDemo.GeneratedMSBuildEditorConfig.editorconfig
-rw-r--r--  1 jamie.hopper  staff   287B  7 Dec 10:21 AccessDeniedDemo.GlobalUsings.g.cs
-rw-r--r--  1 jamie.hopper  staff   145B  7 Dec 10:21 AccessDeniedDemo.assets.cache
-rw-r--r--  1 jamie.hopper  staff    70K  7 Dec 10:21 AccessDeniedDemo.csproj.AssemblyReference.cache
-rw-r--r--  1 jamie.hopper  staff    41B  7 Dec 10:21 AccessDeniedDemo.csproj.CoreCompileInputs.cache
-rw-r--r--  1 jamie.hopper  staff   881B  7 Dec 10:21 AccessDeniedDemo.csproj.FileListAbsolute.txt
-rw-r--r--  1 jamie.hopper  staff   4.5K  7 Dec 10:21 AccessDeniedDemo.dll
-rw-r--r--  1 jamie.hopper  staff    10K  7 Dec 10:21 AccessDeniedDemo.pdb
-rwxr-xr-x@ 1 jamie.hopper  staff   129K  7 Dec 10:21 apphost
drwxr-xr-x  3 jamie.hopper  staff    96B  7 Dec 10:21 ref

Exceptions (if any)

Exception below:

/usr/local/share/dotnet/sdk/6.0.100/Microsoft.Common.CurrentVersion.targets(5100,5): error MSB3021: Unable to copy file "/Users/jamie.hopper/Src/Misc/AccessDeniedDemo/obj/Debug/net6.0/apphost" to "bin/Debug/net6.0/AccessDeniedDemo". Access to the path is denied. [/Users/jamie.hopper/Src/Misc/AccessDeniedDemo/AccessDeniedDemo.csproj]

Further technical details

  • See in repro steps for dotnet info output
  • Consistent behaviour across zsh and pwsh cli instances and from within a terminal instance within vscode
  • Have attempted to uninstall and reinstall desired SDKs using dotnet-core-uninstall tool and searching for references to dotnet and manually removing these directories and their contents.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions