首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >msbuild:无论如何都要显示摘要并使用verbosity=minimal

msbuild:无论如何都要显示摘要并使用verbosity=minimal
EN

Stack Overflow用户
提问于 2011-10-12 00:00:40
回答 2查看 2.2K关注 0票数 8

我有一个用于构建.net解决方案的批处理文件,我正在尝试将详细级别设置为最小,它只显示正在构建的项目以及任何警告和/或错误,但也希望看到最后的摘要,其中包括警告和错误的数量以及构建时间。

我尝试了冗余和/v和/cpl的多种组合,但似乎只能得到太多的输出+摘要或正确的最小输出而没有摘要

有什么想法吗?

提前感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-29 04:39:04

您可以编写一个自定义记录器,如下所述:http://msdn.microsoft.com/en-us/library/ms171471.aspx

下面是一些代码,可以让您开始使用:

代码语言:javascript
复制
public class SummaryLogger : Logger
{
    int warningCount = 0;
    int errorCount = 0;

    public override void Initialize(IEventSource eventSource)
    {
        eventSource.WarningRaised += eventSource_WarningRaised;
        eventSource.ErrorRaised += eventSource_ErrorRaised;
        eventSource.BuildFinished += eventSource_BuildFinished;
    }

    void eventSource_WarningRaised(object sender, BuildWarningEventArgs e)
    {
        warningCount++;
        Console.WriteLine("Warning: " + e.Message);
    }

    void eventSource_ErrorRaised(object sender, BuildErrorEventArgs e)
    {
        errorCount++;
        Console.WriteLine("Error: " + e.Message);
    }

    void eventSource_BuildFinished(object sender, BuildFinishedEventArgs e)
    {
        Console.WriteLine("MSBuild Finished: " + errorCount + " errors | " + warningCount + " warnings.");
    }
}

这个记录器记录警告,错误,并汇总错误和警告的数量。您需要为时间和项目添加一些代码,以便它恰好是您想要的。

要使用它,您需要调用添加了以下参数的MSBuild:

代码语言:javascript
复制
/nologo /noconsolelogger /logger:pathTo/SummaryLogger.dll
票数 3
EN

Stack Overflow用户

发布于 2014-02-02 00:23:51

一种想法是从日志文件中提取所需的信息。

像这样,

代码语言:javascript
复制
Step 1: Redirect your msbuild outputs to a log.txt
Step 2: At the end of the batch file run findstr cmd to look for desired text

示例:

代码语言:javascript
复制
@echo off
setlocal
...
MSBuild /nologo [path to project1 or sln1] [options] >> log.txt
...
MSBuild /nologo [path to project2 or sln2] [options] >> log.txt
...
findstr /irc:"Build*" /c:".*Warning(s)" /c:".*Error(s)" /c:"Time Elapsed.*" log.txt

希望这能有所帮助!

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7729030

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档