dotnet / command-line-api

Command line parsing, invocation, and rendering of terminal output.
https://github.com/dotnet/command-line-api/wiki
MIT License
3.42k stars 382 forks source link

Unable to create Sample App on .NET 5.0.101 #1275

Open mrsauravsahu opened 3 years ago

mrsauravsahu commented 3 years ago

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:

The code in my Program.cs

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>(
              "--int-option",
              getDefaultValue: () => 42,
              description: "An option whose argument is parsed as an int"
          ),
          new Option<bool>(
              "--bool-option",
              "An option whose argument is parsed as a bool"
          ),
          new Option<FileInfo>(
              "--file-option",
              "An option whose argument is parsed as a FileInfo"
          )
      };

      rootCommand.Handler = CommandHandler.Create<int, bool, FileInfo>((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
bklooste commented 3 years ago

Not a command line issue ....if you were to remove the command line lib stuff it would do the same..

Some sort of compiler access to file or file already in use issue.

note it needs access to everythign under /Users/sauravsahu/Documents/personal/code/vpm