0

ac# プログラムで MSBuild の機能を使用する方法に関するいくつかの簡単な回答を探しています。次のような情報しか見つからないため、ネイティブドキュメントはまったく役に立たないようです。

ConsoleLogger.ApplyParameter 
Applies a parameter to the logger

これは、決して書かないほうがよい説明の原型です。ここでも、パラメーターの種類の説明の下にも、パラメーターの目的、名前、またはその情報を見つける場所に関するリンクや例はありません

私が見つけたチュートリアルはすべて、スタンドアロン ツールとしての MSBuild に関するものです。

現時点では、失敗したビルドに関する詳細情報を取得する方法を理解する必要があります。このメソッドは true または false を返すだけです。

bool success = project.Build(new string[] { "Build", "Deploy"}, fileLogger);

また、ファイルロガーを構成する方法と、プロジェクトから使用する方法を理解する必要があります。

Microsoft.Build.Logging.FileLogger fileLogger = new Microsoft.Build.Logging.FileLogger();
4

1 に答える 1

1

質問の特定の例では、ApplyParameterは、コンソールロガーパラメーター(/ clp)がコマンドラインから機能するのと同じように機能します。

> msbuild /?

...

/consoleloggerparameters:<parameters>

 Parameters to console logger. (Short form: /clp)
 The available parameters are:
    PerformanceSummary--Show time spent in tasks, targets
        and projects.
    Summary--Show error and warning summary at the end.
    NoSummary--Don't show error and warning summary at the
        end.
    ErrorsOnly--Show only errors.
    WarningsOnly--Show only warnings.
    NoItemAndPropertyList--Don't show list of items and
        properties at the start of each project build.
    ShowCommandLine--Show TaskCommandLineEvent messages
    ShowTimestamp--Display the Timestamp as a prefix to any
        message.
    ShowEventId--Show eventId for started events, finished
        events, and messages
    ForceNoAlign--Does not align the text to the size of
        the console buffer
    DisableConsoleColor--Use the default console colors
        for all logging messages.
    DisableMPLogging-- Disable the multiprocessor
        logging style of output when running in
        non-multiprocessor mode.
    EnableMPLogging--Enable the multiprocessor logging
        style even when running in non-multiprocessor
        mode. This logging style is on by default.
    Verbosity--overrides the /verbosity setting for this
        logger.
 Example:
    /consoleloggerparameters:PerformanceSummary;NoSummary;
                             Verbosity=minimal

したがって、ヘルプに示されている例では、

logger.ApplyParameter("PerformanceSummary", "NoSummary");
logger.ApplyParameter("Verbosity", "minimal");

コードからビルドエンジンに接続しているロガーを高度に制御する必要がある場合は、ストックコンソールロガーからのテキスト出力を解釈/解析するのではなく、独自のロガーを作成することを検討してください。

于 2011-07-25T20:15:17.653 に答える