Skip to content

Getting "Access to the path ... is denied" on both Windows and macOS #43573

@miquelbeltran

Description

@miquelbeltran

Describe the bug

Added a MAUI Class (library) project to an existing solution.

When I run dotnet build on the solution, I see the following error:

(replaced the solution path by solution-path and the project name by project-name)

CSC : error CS0016: Could not write to output file 'solution-path/project-name/bin/Debug/net8.0-ios' 
-- 'Access to the path 'solution-path/project-name/bin/Debug/net8.0-ios' is denied.' 
[solution-path/project-name/project-name.csproj::TargetFramework=net8.0-ios]

If I go to the project-name directory and I run dotnet build there, it works. It's only when building the solution that it fails.

This happens on:

  • macOS, running dotnet build in the terminal.
  • Windows, running dotnet build in the terminal.
  • Visual Studio on Windows.

Multiple things I have tried:

  • Setting folder permissions.
  • Running as root/sudo/administrator.
  • Disabling any antivirus or security tools.

To Reproduce

I can consistently reproduce this with my solution.

Just add a MAUI library project to it and hit build or build from terminal with dotnet build.

You don't need to change any configs.

This doesn't happen with other project files, seems that only happens with MAUI projects.

Exceptions (if any)

CSC : error CS0016: Could not write to output file 'solution-path/project-name/bin/Debug/net8.0-ios' 
-- 'Access to the path 'solution-path/project-name/bin/Debug/net8.0-ios' is denied.' 
[solution-path/project-name/project-name.csproj::TargetFramework=net8.0-ios]

Further technical details

dotnet --info

.NET SDK:
 Version:           8.0.303
 Commit:            29ab8e3268
 Workload version:  8.0.300-manifests.f51a3a6b
 MSBuild version:   17.10.4+10fbfbf2e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.6
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/8.0.303/

.NET workloads installed:
 [maui-maccatalyst]
   Installation Source: SDK 8.0.300
   Manifest Version:    8.0.82/8.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.82/WorkloadManifest.json
   Install Type:        FileBased

 [maui-ios]
   Installation Source: SDK 8.0.300
   Manifest Version:    8.0.82/8.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.82/WorkloadManifest.json
   Install Type:        FileBased

 [maui-android]
   Installation Source: SDK 8.0.300
   Manifest Version:    8.0.82/8.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.82/WorkloadManifest.json
   Install Type:        FileBased


Host:
  Version:      8.0.7
  Architecture: arm64
  Commit:       2aade6beb0

.NET SDKs installed:
  8.0.203 [/usr/local/share/dotnet/sdk]
  8.0.303 [/usr/local/share/dotnet/sdk]

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

Other architectures found:
  x64   [/usr/local/share/dotnet/x64]
    registered at [/etc/dotnet/install_location_x64]

Environment variables:
  Not set

global.json file:
  [REDACTED]/global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:

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