如何在TFSBuild.proj中添加时间戳? [英] How to add a timestamp to TFSBuild.proj?
问题描述
我有一个TFSBuild.proj文件,我需要添加日期/时间日志以进行统计,即构建的哪些部分花费最多的时间,以及我们在哪里可以改进该过程.
I have a TFSBuild.proj file and I need to add date/time logging for statistics i.e. which parts of the builds take the most time and where can we improve the process.
内部版本将日志输出到BuildLog.txt.我使用以下标记在BuildLog.txt文件中获取自定义消息,但是我需要为每个消息添加时间戳.
The build outputs the log to BuildLog.txt. I use the following tags to get custom messages in the BuildLog.txt file, but I need to add a timestamp to each message.
<Message Text="Debug: BeforeGet start: StartTimeGoesHere"></Message>
<Message Text="Debug: BeforeGet end: EndTimeGoesHere"></Message>
是否可以在消息中获得时间戳记?是否有一个MSBuild变量获取当前日期时间值?在上面的示例中,StartTimeGoesHere将类似于"01 Jan 2001 14:10:12",EndTimeGoesHere将类似于"01 Jan 2001 14:14:43".
Is it possible to get a timestamp in the message? Is there a MSBuild variable that gets the current datetime value? In the example above, StartTimeGoesHere will be something like "01 Jan 2001 14:10:12" and EndTimeGoesHere will be something like "01 Jan 2001 14:14:43".
推荐答案
只要使用MSBuild 4.0,就不需要任何第三方支持.只需在目标中使用属性函数,
You don't need any third party support as long as you are using MSBuild 4.0. Just use a property function within a target,
<PropertyGroup>
<DateTimeNow>$([System.DateTime]::Now)</DateTimeNow>
</PropertyGroup>
这将为$(DateTimeNow)创建以下值,
which will create the following value for $(DateTimeNow),
6/26/2011 9:00:27 PM
这篇关于如何在TFSBuild.proj中添加时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!