该进程无法访问文件,因为在进行 Web 部署时该文件正在被另一个进程使用
我每天使用 TFS 的自动 Web 部署来部署我的构建。在我的网站中,我有一个日志文件。部署时,我收到“该进程无法访问文件,因为该文件正在被另一个进程使用”,此错误导致部署失败。
有人能告诉我如何在自动部署时强制删除旧的吗?我必须执行 IISRESET 才能部署。 谢谢 阿什瓦尼
I am using automatic web deployment from TFS to depoly my build daily. In my web site I have one log file. When deploying I am getting "The process cannot access a file because it is being used by another process" this error causes deployment to fail.
Can anybody tell me how to force delete of the old while automatic deploying? I have to do IISRESET to deploy.
Thanks
Ashwani
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在尝试部署之前,您需要执行完整的
iisreset /stop
,然后在部署成功后使用iisreset /start
重新启动服务器。或者,如果同一主机上有其他网站,请尝试自行停止应用程序池,进行部署,然后重新启动应用程序。水池。您可以使用
appcmd
执行此操作:appcmd list apppool
列出您的应用程序池appcmd stop apppool
停止池appcmd start apppool
启动池要从 MSBuild 执行此操作,请尝试扩展包。
You'll want to do a full
iisreset /stop
before you attempt your deployment, then after the deployment is successful restart your server withiisreset /start
.Alternatively, if you have other Web sites on the same host, try stopping the application pool by itself, deploying, then restarting the app. pool. You can use
appcmd
for this:appcmd list apppool
lists your application poolsappcmd stop apppool <name>
stops a poolappcmd start apppool <name>
starts a poolTo do this from MSBuild, try the extension pack.
如果为 FlatfileTraceListener 指定的文件是只读的,则跟踪侦听器不会将数据写入该文件,并且不会发生异常。确保文件属性设置为读/写。
当您使用 FlatFileTraceListener 类将日志信息写入文件时,应用程序块会锁定该文件,直到应用程序关闭。可以打开并读取该文件,但在关闭应用程序之前无法移动或删除日志文件。
https://msdn.microsoft.com/en-us/library/ff648115.aspx
If the file you specify for the FlatfileTraceListener is read-only, the trace listener does not write the data to the file and no exception occurs. Make sure that the file attributes are set to read/write.
When you use the FlatFileTraceListener class to write log information to a file, the application block locks the file until the application closes. It is possible to open and read the file but you cannot move or delete the log file until you close the application.
https://msdn.microsoft.com/en-us/library/ff648115.aspx