dotnet / dotnet/command-line-api
Unable to create Sample App on .NET 5.0.101
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
Expected Result: Sample app should create a simple CLI tool
Actual Result: Both `dotnet build` and `dotnet run` failed with 'Access Denied' issues
Output of `dotnet build`
```
➜ dotnet build
Microsoft (R) Build Engine version 16.8.0+126527ff1 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
/Users/sauravsahu/.cli-config/current/dotnet/sdk/5.0.101/Microsoft.Common.CurrentVersion.targets(4354,5): error MSB3021: Unable to copy file "obj/Debug/net5.0/helloWorld.dll" to "bin/Debug/net5.0/helloWorld.dll". Access to the path '/Users/sauravsahu/Documents/personal/code/vpm/obj/Debug/net5.0/helloWorld.dll' is denied. [/Users/sauravsahu/Documents/personal/code/vpm/helloWorld.csproj]
Build FAILED.
/Users/sauravsahu/.cli-config/current/dotnet/sdk/5.0.101/Microsoft.Common.CurrentVersion.targets(4354,5): error MSB3021: Unable to copy file "obj/Debug/net5.0/helloWorld.dll" to "bin/Debug/net5.0/helloWorld.dll". Access to the path '/Users/sauravsahu/Documents/personal/code/vpm/obj/Debug/net5.0/helloWorld.dll' is denied. [/Users/sauravsahu/Documents/personal/code/vpm/helloWorld.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:02.80
```
Output of `dotnet run`
```
➜ dotnet run
/Users/sauravsahu/.cli-config/current/dotnet/sdk/5.0.101/Microsoft.Common.CurrentVersion.targets(4354,5): error MSB3021: Unable to copy file "obj/Debug/net5.0/helloWorld.dll" to "bin/Debug/net5.0/helloWorld.dll". Access to the path '/Users/sauravsahu/Documents/personal/code/vpm/obj/Debug/net5.0/helloWorld.dll' is denied. [/Users/sauravsahu/Documents/personal/code/vpm/helloWorld.csproj]
The build failed. Fix the build errors and run again.
```
Checks:
- Checked the file permissions and I have `drwxr-xr-x` in `bin/Debug/net5.0` and `obj/Debug/net5.0` and my user is the owner of the folders
The code in my Program.cs
```csharp
using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.IO;
namespace HelloWorld
{
class Program
{
static int Main(string[] args)
{
var rootCommand = new RootCommand("Hello world CLI with System.CommandLine")
{
new Option(
"--int-option",
getDefaultValue: () => 42,
description: "An option whose argument is parsed as an int"
),
new Option(
"--bool-option",
"An option whose argument is parsed as a bool"
),
new Option(
"--file-option",
"An option whose argument is parsed as a FileInfo"
)
};
rootCommand.Handler = CommandHandler.Create((intOption, boolOption, fileOption) =>
{
Console.WriteLine($"The value for --int-option is: {intOption}");
Console.WriteLine($"The value for --bool-option is: {boolOption}");
Console.WriteLine($"The value for --file-option is: {fileOption?.FullName ?? "null"}");
});
return rootCommand.InvokeAsync(args).Result;
}
}
}
```
My .NET info
```
➜ dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.101
Commit: d05174dc5a
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /Users/sauravsahu/.cli-config/current/dotnet/sdk/5.0.101/
Host (useful for support):
Version: 5.0.1
Commit: b02e13abab
.NET SDKs installed:
5.0.101 [/Users/sauravsahu/.cli-config/current/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.1 [/Users/sauravsahu/.cli-config/current/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.1 [/Users/sauravsahu/.cli-config/current/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
```
Contributor guide
Assessment
This issue has not been assessed yet.