26

在构建日志中,我想知道每个项目编译的开始和结束时间。有没有办法让 VS 做到这一点?

4

5 回答 5

34

其他选项是提高 MSBuild 详细程度。

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

设置MSBuild project build output verbosityNormal。这会给你这样的输出:

------ Build started: MyProject, Configuration: Debug x86 ------
Build started 24/03/2014 08:46:18.
...
Build succeeded.

Time Elapsed 00:00:05.18
于 2014-03-24T07:54:58.607 回答
12

对于 VC++ 构建,您可以启用构建时间。转到工具-> 选项-> 项目和解决方案-> VC++ 项目设置并选择“构建时序”选项

于 2008-09-05T18:43:51.020 回答
9

Time我发现的一种新方法是在 post event PrePost-build event 命令行中调用命令:

TIME /T
于 2010-07-22T19:27:50.173 回答
0

必须修改实际项目文件(使用文本编辑器)以将调用添加到 MSBuild 脚本目标。

于 2008-09-05T18:44:12.533 回答
0

带有脚本文件的替代解决方案...还包括项目构建的经过时间。

在您的项目共享空间“GetTime.vbs”VBS 代码的某处创建 VBS 文件...

dim out : Set out = WScript.StdOut
Set objShell = WScript.CreateObject("WScript.Shell")
dim regDir: regDir="HKEY_CURRENT_USER\Software\VB and VBA Program Settings\GetTime.vbs\"
dim msg: msg=""
dim s: s=""
dim e: e=""
dim st:st=""
' param s is start flag keyed to the application being built.
if wscript.arguments.named.exists("s") then
    s = wscript.arguments.named("s")
    objShell.RegWrite regdir & s,now
end if
if wscript.arguments.named.exists("e") then
    e = wscript.arguments.named("e")
    st = cdate(objShell.RegRead(regDir & e))
end if 

if e<>"" and isdate(st) then
    out.writeline e & " ENDED " & now & " ELAPSED " & datediff("s",cdate(st),now) & " seconds"
elseif e<>"" then
    out.writeline e & " ENDED " & now
elseif s<>"" then
    out.writeline s & " STARTED " & now
else
    out.writeline now
end if 

更改您的构建事件以包含此脚本和一些参数......(您需要更改相对于输出目录的目录路径以从多个项目中查找文件)

预构建事件命令行...

cscript "../../../../Scorecards/gettime.vbs" //B /s:"$(ProjectName)"

构建后事件命令行

cscript "../../../../Scorecards/gettime.vbs" //B /e:"$(ProjectName)"

多个项目的示例输出...

2>  OPResources STARTED 7/9/2020 12:59:04 PM
2>  ...
2>  OPResources ENDED 7/9/2020 12:59:05 PM ELAPSED 1 seconds
1>  OPLib_WF STARTED 7/9/2020 12:59:04 PM
1>  ...
1>  OPLib_WF ENDED 7/9/2020 12:59:05 PM ELAPSED 1 seconds
4>------ Rebuild All started: Project: OPLib, Configuration: Debug Any CPU ------
4>  OPLib STARTED 7/9/2020 12:59:06 PM
4> ...
4>  OPLib ENDED 7/9/2020 12:59:10 PM ELAPSED 4 seconds
5>------ Rebuild All started: Project: PerfUpdater, Configuration: Debug Any CPU ------
6>------ Rebuild All started: Project: Scorecards2, Configuration: Debug Any CPU ------
7>------ Rebuild All started: Project: SingleSignOn, Configuration: Debug Any CPU ------
7>  SingleSignOn STARTED 7/9/2020 12:59:10 PM
7>  ...
7>  SingleSignOn ENDED 7/9/2020 12:59:12 PM ELAPSED 2 seconds
于 2020-07-09T17:02:26.923 回答