有没有办法在 Visual Studio 中显示整个解决方案的构建时间?

发布于 2024-08-18 16:08:01 字数 126 浏览 3 评论 0原文

我知道有一种方法可以在视觉中显示解决方案中包含的每个项目的构建时间工作室。但我正在寻找的是构建整个解决方案所需的总时间,从我单击构建的那一刻到完成的那一刻。

有办法做到这一点吗?运行 Visual Studio 2008。

I know there is a way to display the build time of each project contained in a solution in visual studio. But what I'm looking for is the total time it took to build an entire solution, from the moment I clicked on build, to the moment it was done.

Is there anyway to do this ? Running Visual Studio 2008.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

朕就是辣么酷 2024-08-25 16:08:01

编辑:这是一种可以将构建时间直接写入构建窗口的方法。

打开 Visual Studio 宏 IDE。
导航至“我的宏”>环境事件。
在 MyMacros 下,添加对 System.Windows.Forms 的引用(以便下面的代码显示弹出窗口)。
将此代码添加到 EnvironmentEvents 模块:

Dim buildStart As Date

Private Function IsBuild(ByVal scope As EnvDTE.vsBuildScope, ByVal action As EnvDTE.vsBuildAction) As Boolean
    Return scope = vsBuildScope.vsBuildScopeSolution AndAlso (action = vsBuildAction.vsBuildActionBuild OrElse action = vsBuildAction.vsBuildActionRebuildAll)
End Function

Private Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin
    If (IsBuild(Scope, Action)) Then
        buildStart = Date.Now
    End If
End Sub

Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone
    If (IsBuild(Scope, Action)) Then
        Dim buildTime = Date.Now - buildStart
        WriteToBuildWindow(String.Format("Build time: {0}", buildTime.ToString))
    End If
End Sub

Private Sub WriteToBuildWindow(ByVal message As String)
    Dim win As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
    Dim ow As OutputWindow = CType(win.Object, OutputWindow)
    For Each owPane As OutputWindowPane In ow.OutputWindowPanes
        If (owPane.Name.Equals("Build")) Then
            owPane.OutputString(message)
            Exit For
        End If
    Next
End Sub

当您构建或重建完整的解决方案时,最后,构建/重建持续时间将打印到构建输出窗口。您可以更改 IsBuild 中的条件以满足您的喜好。

EDIT: Here's a way you can write the build time directly to the build window.

Open the Visual Studio Macro IDE.
Navigate to MyMacros > EnvironmentEvents.
Under MyMacros, add a reference to System.Windows.Forms (for the code below to show a popup window).
Add this code to the EnvironmentEvents module:

Dim buildStart As Date

Private Function IsBuild(ByVal scope As EnvDTE.vsBuildScope, ByVal action As EnvDTE.vsBuildAction) As Boolean
    Return scope = vsBuildScope.vsBuildScopeSolution AndAlso (action = vsBuildAction.vsBuildActionBuild OrElse action = vsBuildAction.vsBuildActionRebuildAll)
End Function

Private Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin
    If (IsBuild(Scope, Action)) Then
        buildStart = Date.Now
    End If
End Sub

Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone
    If (IsBuild(Scope, Action)) Then
        Dim buildTime = Date.Now - buildStart
        WriteToBuildWindow(String.Format("Build time: {0}", buildTime.ToString))
    End If
End Sub

Private Sub WriteToBuildWindow(ByVal message As String)
    Dim win As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
    Dim ow As OutputWindow = CType(win.Object, OutputWindow)
    For Each owPane As OutputWindowPane In ow.OutputWindowPanes
        If (owPane.Name.Equals("Build")) Then
            owPane.OutputString(message)
            Exit For
        End If
    Next
End Sub

When you build or rebuild the full solution, at the end, the build/rebuild duration will be printed to the build output window. You can change the conditions in IsBuild to suit your preferences.

海拔太高太耀眼 2024-08-25 16:08:01

工具->选项->项目和解决方案->VC++项目设置->构建计时

Tools->Options->Projects and Solutions->VC++ Project Settings->Build Timing

若能看破又如何 2024-08-25 16:08:01

这是一个老问题,但我认为有些人可能仍然觉得它有用。

我已经为 VS2015 和 VS2017 编写了扩展。它显示每个项目的开始和结束时间,相对于整个构建的开始时间来表示。因此,最后一个项目的结束时间是解决方案的总构建时间。

我在此处发布了有关该扩展的更多信息。

That's an old question but I thought some may still find it useful.

I have written an extension for VS2015 and VS2017. It displays the start and end time for each project, expressed relative to the start of the overall build. Hence the end time of the last project is the total build time for the solution.

I have posted more about the extension here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文