MSBuild中的电子邮件错误 - ReadLinesFromFile“被另一个进程” [英] Email Errors in MSBuild - ReadLinesFromFile "is being used by another process"

查看:495
本文介绍了MSBuild中的电子邮件错误 - ReadLinesFromFile“被另一个进程”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从这里实现答案:
如何访问MSBuild中的错误详细信息

 > msbuild MyProject.proj / fl /flp:v=detailed;logfile=mylog.txt 

<目标名称=ErrorEmail>
< ReadLinesFromFile
File =mylog.txt
Lines =_ ErrorLines
/>
< Mail
SmtpServer =mysrv
From =me @ mysrv
To =error @ mysrv
主题=发生错误
Body =错误详细信息:@(_ ErrorLines,'%0D%0A')
/>
< / Target>

看起来很优雅,但我收到这个错误:


c:\AccuRev\Build_2012_01_02\MyApp\ErrorHandlers.targets(24,9):
错误MSB3501:无法从文件mylog中读取行。文本。
进程无法访问文件
'c:\AccuRev\Build_2012_01_02\MyApp\mylog.txt',因为
正在被另一个进程使用



解决方案

mylog.txt文件被锁定,因为您正在为构建日志和ReadLinesFromFile任务使用相同的文件。 / p>

编辑:尝试执行MSBuild 2次。首先建立你的项目和第二次发送电子邮件。使用/flp1:logfile=errors.txt使用 distributedFileLogger 命令行开关; erroronly命令行参数将所有错误记录到errors.txt。然后,您可以将此文件附加到您的电子邮件中,而无需发送整个构建日志。


I'm trying to implement the answer from here: How to access error details in MSBuild

> msbuild MyProject.proj /fl /flp:v=detailed;logfile=mylog.txt

<Target Name="ErrorEmail">
   <ReadLinesFromFile
      File="mylog.txt"
      Lines="_ErrorLines"
      />
   <Mail
      SmtpServer="mysrv"
      From="me@mysrv"
      To="error@mysrv"
      Subject="An error occured"
      Body="Error details: @(_ErrorLines, '%0D%0A')"
      />
</Target>

Looks elegant, but I'm getting this error:

c:\AccuRev\Build_2012_01_02\MyApp\ErrorHandlers.targets(24,9): error MSB3501: Could not read lines from file "mylog.txt". The process cannot access the file 'c:\AccuRev\Build_2012_01_02\MyApp\mylog.txt' because it is being used by another process

解决方案

mylog.txt file is locked because you are using the same file for build log and for the ReadLinesFromFile task.

EDIT: Try to execute MSBuild 2 times. First to build your projects and 2nd time to send an email. Use distributedFileLogger command line switch with /flp1:logfile=errors.txt;errorsonly command line parameters to log all errors to errors.txt. You can then attach this file into your email without sending whole build log.

这篇关于MSBuild中的电子邮件错误 - ReadLinesFromFile“被另一个进程”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆