【发布时间】:2010-09-07 23:20:19
【问题描述】:
在构建日志中,我想记录每个项目编译的开始和结束时间。有没有办法让 VS 做到这一点?
【问题讨论】:
标签: visual-studio build
在构建日志中,我想记录每个项目编译的开始和结束时间。有没有办法让 VS 做到这一点?
【问题讨论】:
标签: visual-studio build
其他选项是提高 MSBuild 详细程度。
Tools -> Options -> Projects and Solutions -> Build and Run ->
将MSBuild project build output verbosity 设置为Normal。这会给你这样的输出:
------ Build started: MyProject, Configuration: Debug x86 ------
Build started 24/03/2014 08:46:18.
...
Build succeeded.
Time Elapsed 00:00:05.18
【讨论】:
对于 VC++ 构建,您可以启用构建时序。转到工具->选项->项目和解决方案->VC++项目设置并选择“构建时序”选项
【讨论】:
我发现的一种新方法是在 post event Pre 和 Post-build event 命令行中调用Time 命令:
TIME /T
【讨论】:
必须修改实际项目文件(使用文本编辑器)以将调用添加到 MSBuild 脚本目标。
【讨论】:
脚本文件的替代解决方案... 还包括项目构建的经过时间。
在项目共享空间“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
【讨论】: