CommandLineParser packageとVisual Studio Professional 2015(Update 3)を使用してコマンドライン引数を解析するときに発生するエラーを確認しようとしています。私は偽に設定するoptionsAreValid
がDebug > Windows > Output
ウィンドウに表示される原因となる問題について、いくつかの役立つ情報を参照してください期待していたVisual Studio 2015でCommandLineParserの解析エラーを表示する方法はありますか?
using System;
using System.IO;
namespace SampleParser
{
class Program
{
static void Main(string[] args)
{
// Set the CommandLineParser configuration options.
var commandLineParser = new CommandLine.Parser(x =>
{
x.MutuallyExclusive = true;
x.HelpWriter = Console.Error;
x.IgnoreUnknownArguments = false;
});
// Parse the command-line arguments.
var options = new CommandLineOptions();
var optionsAreValid = commandLineParser.ParseArguments(args, options);
if (!optionsAreValid)
{
return;
}
}
}
}
:ここでは私が働いているコードがあります。しかし、何も表示されません...私は間違ったことをしていますか、間違った場所を探していますか、この情報を見る前にトグルする必要がある他の設定がありますか?私は誤ってHelpText
プロパティがビジュアルに情報を送信すると仮定
namespace SampleParser
{
class CommandLineOptions
{
[Option(HelpText = @"When set to ""true"", running the application will not make any changes.", Required = false)]
public bool Preview { get; set; }
[HelpOption]
public string GetUsage()
{
return HelpText.AutoBuild(this, current => HelpText.DefaultParsingErrorsHandler(this, current));
}
}
}
あなたは 'CommandLineOptions'クラスで定義されたルール/オプションを持っていますか? – NicoE
はい - 使用しているルール/オプションクラスを含むようにOPを更新しました。 –
一般に、Visual Studioの出力ウィンドウに出力するには、DebugクラスまたはTraceクラスのメソッドを明示的に呼び出す必要があります。 'optionsAreValid'が真であるためには、 'cmd --preview'を使ってcmdを呼び出すか、引数なしで 'cmd'だけを呼び出すべきです。 – NicoE