visual-studio 在 Visual Studio 中显示构建时间?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/82128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:30:58  来源:igfitidea点击:

Displaying build times in Visual Studio?

visual-studiomsbuildbuild-process

提问by Roger Lipscombe

Our build server is taking too long to build one of our C++ projects. It uses Visual Studio 2008. Is there any way to get devenv.com to log the time taken to build each project in the solution, so that I know where to focus my efforts?

我们的构建服务器花费太长时间来构建我们的 C++ 项目之一。它使用 Visual Studio 2008。有什么方法可以让 devenv.com 记录在解决方案中构建每个项目所花费的时间,以便我知道我的工作重点在哪里?

Improved hardware is not an option in this case.

在这种情况下,改进硬件不是一种选择。

I've tried setting the output verbosity (under Tools / Options / Projects and Solutions / Build and Run / MSBuild project build output verbosity). This doesn't seem to have any effect in the IDE.

我试过设置输出详细程度(在工具/选项/项目和解决方案/构建和运行/MSBuild 项目构建输出详细程度下)。这在 IDE 中似乎没有任何影响。

When running MSBuild from the command line (and, for Visual Studio 2008, it needs to be MSBuild v3.5), it displays the total time elapsed at the end, but not in the IDE.

从命令行运行 MSBuild 时(对于 Visual Studio 2008,它需要是 MSBuild v3.5),它会显示最后经过的总时间,但不会在 IDE 中显示。

I really wanted a time-taken report for each project in the solution, so that I could figure out where the build process was taking its time.

我真的想要解决方案中每个项目的耗时报告,以便我可以找出构建过程花费的时间。

Alternatively, since we actually use NAnt to drive the build process (we use Jetbrains TeamCity), is there a way to get NAnt to tell me the time taken for each step?

或者,由于我们实际上使用 NAnt 来驱动构建过程(我们使用 Jetbrains TeamCity),有没有办法让 NAnt 告诉我每一步所用的时间?

回答by JesperE

Menu ToolsOptionsProjects and SolutionsVC++ Project SettingsBuild Timingshould work.

菜单工具选项项目和解决方案VC++ 项目设置构建时间应该可以工作。

回答by Dave Moore

Go to Tools → Options → Projects and Solutions → Build and Run → MSBuild project build output verbosity - set to "Normal" or "Detailed", and the build time will appear in the output window.

转到工具 → 选项 → 项目和解决方案 → 构建和运行 → MSBuild 项目构建输出详细程度 - 设置为“正常”或“详细”,构建时间将出现在输出窗口中。

回答by Sebastian

Visual Studio 2012 - 2019

Visual Studio 2012 - 2019

  • For MSBuild Projects (e.g. all .Net-Projects):
    Click Tools -> Optionsand then select Projects and Solutions -> Build and Run. Change MSBuild project build output verbosityto Normal. So it will display Time Elapsed in every Solution Project it builds. But there is unfortunatily no Elapsed Time Sum over all project. You will also see the Build started Timestamp

  • FOR C/C++ Project:

  • 对于 MSBuild 项目(例如所有 .Net 项目):
    单击Tools -> Options,然后选择Projects and Solutions -> Build and Run。更改MSBuild project build output verbosityNormal。所以它会在它构建的每个解决方案项目中显示 Time Elapsed。但不幸的是,所有项目都没有 Elapsed Time Sum。您还将看到构建开始的时间戳

  • 对于 C/C++ 项目:

Click Tools -> Optionsand then select Projects and Solutions -> VC++ Project Settings.

单击Tools -> Options,然后选择Projects and Solutions -> VC++ Project Settings

Change Build Timingto Yes.

更改Build TimingYes

回答by Oliver

For Visual Studio 2012 you could use the Build Monitorextension.

对于 Visual Studio 2012,您可以使用Build Monitor扩展。

回答by MattyT

If you're stuck on VS2005 you could use the vs-build-timer plugin. At the completion of a build it shows the total time taken and a (optional) summary of each of the project durations.

如果你坚持使用 VS2005,你可以使用vs-build-timer 插件。在构建完成时,它会显示花费的总时间和每个项目持续时间的(可选)摘要。

Disclaimer; I wrote it. And yes, I need to create an installer...one day!

免责声明;我写的。是的,我需要创建一个安装程序......总有一天!

回答by RaaFFC

Tools->Options->Projects and Solutions->Build and Run->

工具->选项->项目和解决方案->构建和运行->

Set "MSBuild project build output verbosity" from "Minimal" to "Normal"

将“MSBuild 项目构建输出详细程度”从“最小”设置为“正常”

回答by Dave Moore

Since your question involves using DevEnv from the command line, I would also suggest using MSBuild(which can build .sln files without modification).

由于您的问题涉及从命令行使用 DevEnv,我还建议使用MSBuild(它可以在不修改的情况下构建 .sln 文件)。

msbuild /fl /flp:Verbosity=diagnostic Your.sln

msbuild /?will show you other useful options for the filelogger.

msbuild /?将向您展示文件记录器的其他有用选项。

回答by buildops

If you want to visualize your build you can use IncrediBuild. IncrediBuild's now available in standalone-mode (not distributed but for use only on 8 cores on your local machine) for free as part of Visual Studio 2015 Update 1

如果您想可视化您的构建,您可以使用 IncrediBuild。IncrediBuild 现在作为 Visual Studio 2015 更新 1 的一部分免费提供独立模式(非分布式,但仅用于本地机器上的 8 个内核)

Disclaimer: I work for IncrediBuild

免责声明:我为 IncrediBuild 工作

回答by opetroch

I have created an extension to measure the build times and present the order of events in a graph: Visual Studio Build Timer.

我创建了一个扩展来测量构建时间并在图表中显示事件的顺序:Visual Studio Build Timer

enter image description here

在此处输入图片说明

It is available on visual studio market place and works for VS2015, VS2017 and VS2019.

它在 Visual Studio 市场上可用,适用于 VS2015、VS2017 和 VS2019。

I find the visual presentation quite helpful. Apart from showing which projects take longer, it also shows dependencies between them, i.e. projects that wait for others to complete before they start. This way you can spot bottlenecks in the build and see what dependencies need to break in order to increase the parallelization of your build.

我发现视觉呈现很有帮助。除了显示哪些项目需要更长的时间之外,它还显示了它们之间的依赖关系,即在开始之前等待其他人完成的项目。通过这种方式,您可以发现构建中的瓶颈,并查看需要打破哪些依赖项以提高构建的并行度。

回答by InbetweenWeekends

I ended up here because I just wanted the date and time included in the build output. Should others be searching for something similar it's as simple as adding echo %date% %time%to the Pre-build and/or Post-build events under project, PropertiesCompileBuild Events.

我最终来到这里是因为我只想要包含在构建输出中的日期和时间。如果其他人正在搜索类似的东西,它就像添加echo %date% %time%到项目下的 Pre-build 和/或 Post-build 事件一样简单,PropertiesCompileBuild Events