有没有办法在MSBuild(版本3.5)中轻松输出当前时间?
我想在调用 MSBuild 3.5 时输出当前时间(最好在每个任务之前或至少在开始/完成每个目标时)。
我尝试创建一个我会不断调用的目标,如下所示:
<Target Name="EchoTime">
<Time Format="yyyy-MM-dd HH:mm:ss.fff">
<Output TaskParameter="FormattedTime" PropertyName="currentTime" />
</Time>
<Message Text = "$(currentTime)" />
</Target>
...但事实证明,一个目标每次执行只能调用另一个目标一次。
所以如果我尝试...
<Target Name="TimeTest" >
<Message Text = "--------------------------------------------------" />
<CallTarget Targets="EchoTime" />
<Message Text = " " />
<Message Text = "Try calling EchoTime again" />
<Message Text = " " />
<CallTarget Targets="EchoTime" />
<Message Text = "--------------------------------------------------" />
</Target>
那么输出看起来像...
Build started 10/12/2011 2:24:52 PM.
Project "C:\Temp\MSBuildSandbox\MSBuild_EchoTime.xml" on node 0 (TimeTest target(s)).
--------------------------------------------------
EchoTime:
2011-10-12 14:24:52.756
TimeTest:
Try calling EchoTime again
--------------------------------------------------
Done Building Project "C:\Temp\MSBuildSandbox\MSBuild_EchoTime.xml" (TimeTest target(s)).
有人知道实现此目的的简单方法吗?
I'd like to output the current time (preferably before every task or at minimum when starting/completing every target) when invoking MSBuild 3.5.
I tried creating a target that I would continually call that looks like:
<Target Name="EchoTime">
<Time Format="yyyy-MM-dd HH:mm:ss.fff">
<Output TaskParameter="FormattedTime" PropertyName="currentTime" />
</Time>
<Message Text = "$(currentTime)" />
</Target>
...but it turns out that one target can only call another target once per execution.
So if I try...
<Target Name="TimeTest" >
<Message Text = "--------------------------------------------------" />
<CallTarget Targets="EchoTime" />
<Message Text = " " />
<Message Text = "Try calling EchoTime again" />
<Message Text = " " />
<CallTarget Targets="EchoTime" />
<Message Text = "--------------------------------------------------" />
</Target>
Then the output looks like...
Build started 10/12/2011 2:24:52 PM.
Project "C:\Temp\MSBuildSandbox\MSBuild_EchoTime.xml" on node 0 (TimeTest target(s)).
--------------------------------------------------
EchoTime:
2011-10-12 14:24:52.756
TimeTest:
Try calling EchoTime again
--------------------------------------------------
Done Building Project "C:\Temp\MSBuildSandbox\MSBuild_EchoTime.xml" (TimeTest target(s)).
Anyone know an easy way to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CallTarget
无法执行同一目标两次,但有一个 解决方法:请注意,为每个后续调用将
prop1
的值设置为不同的值。CallTarget
cannot execute the same target twice but there's a workaround using theMSBuild
task:Note setting the value for
prop1
to a different value for each subsequent call.