如何阻止 asp.net 阻止对文件的访问,然后在构建时抛出访问被拒绝的错误? [英] How can I stop asp.net from blocking access to files then throwing access denied errors on build?

查看:23
本文介绍了如何阻止 asp.net 阻止对文件的访问,然后在构建时抛出访问被拒绝的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我反复遇到以下构建错误:

I repeatedly get build errors along the lines of the following:

无法使以下项目可运行:<项目名称>(.NETFramework,Version=v4.6.1) 原因:从root访问路径'C:<path>src<项目名称>inDebug et641win7-64x<某些 dll、exe、config 以及任何>'被拒绝.

Failed to make the following project runnable: <project name>(.NETFramework,Version=v4.6.1) reason: Access to the path 'C:<path from root>src<project name>inDebug et641win7-64x<some dll, exe, config, whatever>' is denied.

我从其他文件夹中收到了类似的错误,但将它们从源代码管理中移除有帮助(见下文)

I was getting similar errors from other folders but taking them out of source control helped (see below)

有时手动转到资源管理器中的文件夹 > 右键单击​​ > 属性 > 取消选中只读"适用于成功构建但随后 VS 或 TFS 再次锁定文件并返回相同的构建错误

Sometimes manually going to the folder in Explorer > right click > properties > uncheck "read only" works for a successful build but then either VS or TFS locks the file again and the same build error returns

特别是目前有两个 .dll 文件被添加到 bin 中,它们被重复设置为只读",我必须在重建时在文件资源管理器中手动修复它.AFAIK 这些不在源代码管理中,但解决方案中另一个项目中同名的文件已签入且未更改.

In particular at the moment there are two .dll files being added to the bin which are repeatedly set to "read only" and I have to manually fix that in file explorer upon rebuild. AFAIK these are not in source control, but the files in another project within the solution by the same name are checked in and not changing.

这可能与我使用的是尚未正式的​​ asp.net Core RC2 的事实有关,而且我正在将它与 配对>Angular 2 RC1 但我认为这不相关.

It may have something to do with the fact I'm using asp.net Core RC2 which is not official yet, plus I'm pairing it with Angular 2 RC1 but I don't think that's related.

一种理论认为它与 TFS 有关,因为在我将项目置于源代码控制之下之前,错误似乎不会开始.

One theory is that it has something to do with TFS since the errors don't seem to start until I put the project under source control.

我在 Stack Overflow 上看到了许多类似的问题,但没有答案甚至开始解决我自己的重复问题.

I've seen a number of similar questions on Stack Overflow but no answers that even begin to resolve my own repetitive problem.

提示:我对转译的 .ts > .js 文件进行了同样的处理,并将它们从源代码管理中移除似乎有所帮助,但我根本没有在源代码管理中看到 bin 文件夹(当然它隐藏在解决方案资源管理器,我看不到在源代码管理资源管理器中取消隐藏的选项,所以不确定它是否在那里...)

HINT: I was getting the same with transpiled .ts > .js files and taking them out of source control seems to have helped but I don't see the bin folder in source control at all (of course it's hidden in the solution explorer and I see no option to unhide in source control explorer, so not sure if it's there at all...)

推荐答案

我在脚本部分添加了一个后编译:

I've added in the script section a postcompile:

"postcompile": [
  "cmd /c echo Removing read-only attributes in %project:Directory%\bin\ && cmd /c attrib -r  %project:Directory%\bin\* /s",
  "cmd /c echo Removing read-only attributes in %project:Directory%\..\packages\ && cmd /c attrib -r  %project:Directory%\..\packages\* /s"
]

对我来说效果很好

这篇关于如何阻止 asp.net 阻止对文件的访问,然后在构建时抛出访问被拒绝的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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