小编Haw*_*ale的帖子

我的 System.CommandLine 应用程序无法构建!它找不到 CommandHandler。我需要写吗?

我正在使用 VS 2022、.Net 6.0,并尝试使用 .Net 构建我的第一个应用程序System.CommandLine

问题:当我构建它时,出现错误

当前上下文中不存在名称“CommandHandler”

我尝试构建的代码是来自 GitHub 站点的示例应用程序:https ://github.com/dotnet/command-line-api/blob/main/docs/Your-first-app-with-System-CommandLine .md,无需更改(我认为)。

它看起来像这样:

using System;
using System.CommandLine;
using System.IO;

static int Main(string[] args)
{
    // Create a root command with some options
    var rootCommand = new RootCommand
        { 
        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 …
Run Code Online (Sandbox Code Playgroud)

c# system.commandline

14
推荐指数
1
解决办法
6265
查看次数

标签 统计

c# ×1

system.commandline ×1