command-line-api icon indicating copy to clipboard operation
command-line-api copied to clipboard

Type or namespace name 'CliCommand' not found.

Open johnholliday opened this issue 1 year ago • 7 comments

Simple application fails to resolve.

Program.cs

using System.CommandLine;

public class SampleCommand : CliCommand // <-- CS0246
{

}

TestProgram.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
    <PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
  </ItemGroup>

</Project>

johnholliday avatar Sep 02 '24 20:09 johnholliday

Is there any workaround?

NeverMorewd avatar Sep 04 '24 02:09 NeverMorewd

2.0.0-beta4.22272.1 is two years old. In that version, the class is named System.CommandLine.Command: https://github.com/dotnet/command-line-api/blob/209b724a3c843253d3071e8348c353b297b0b8b5/src/System.CommandLine/Command.cs#L21

KalleOlaviNiemitalo avatar Sep 04 '24 03:09 KalleOlaviNiemitalo

Add a nuget source and update the nuget version to 2.0.0-beta4.24324.3 Daily builds are available if you add this feed to your nuget.config: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json

NeverMorewd avatar Sep 04 '24 03:09 NeverMorewd

If you have an application using System.CommandLine 2.0.0-beta4.22272.1 and you upgrade to 2.0.0-beta4.24324.3 from that dnceng feed, you need to adapt the app to breaking changes in the API… and then there'll be more API breaks if the main-powderhouse branch is eventually merged and released.

I haven't seen any promises about how long the https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json feed will exist. If I used packages from that in production, I'd make sure to archive them locally, so as to keep old versions of my app buildable even if the feed is deleted in the future.

KalleOlaviNiemitalo avatar Sep 04 '24 05:09 KalleOlaviNiemitalo

Where can I find the current / latest documentation from. I updated from 2.0.0-beta4.22272.1 to 2.0.0-beta4.24324.3 . But there are a lot of changes, even breaking ones. But the docu is still on 2022 or 2023. Even there is no "hello-world" cli working example, with the newer versions of the CLI nuget package.

Developers are lost in the early beginning ...

N7K4 avatar Sep 26 '24 08:09 N7K4

There is no documentation for the latest betas. It would be a waste of time anyway as the PowderHouse will completely change once again.

Balkoth avatar Sep 27 '24 08:09 Balkoth

Up-to-date documentation for the main and main-powderhouse branches is not published.

@N7K4, if you are making a commercial product, I don't recommend using System.CommandLine in its current state, when there are only preview releases. Better use a different package or write your own parser.

If you're instead hacking on a hobby project, then I suppose you can use DocFX to generate API reference documentation in HTML. Concept documentation and examples would be missing though, so you'd have to spend time perusing the implementation.

KalleOlaviNiemitalo avatar Sep 27 '24 11:09 KalleOlaviNiemitalo

We had renamed Command to CliCommand for a while but reverted that in the 2.0.0-beta5 release.

See: Announcing System.CommandLine 2.0.0-beta5 and our path to a stable release #2576

jeffhandley avatar Jun 20 '25 06:06 jeffhandley