visual-studio Visual Studio 发布失败:“无法删除文件......访问路径......被拒绝。”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3628348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:25:05  来源:igfitidea点击:

Visual Studio Publish Failed: "Unable to delete file ... Access to the path ... is denied."

visual-studiosvntortoisesvn

提问by Zack Peterson

I've recently switched from a Windows XP machine to Windows 7. I use Subversion and TortoiseSVN.

我最近从 Windows XP 机器切换到 Windows 7。我使用 Subversion 和 TortoiseSVN。

I cannot publish my .NET application in Visual Studio. I get over a thousand errors like this:

我无法在 Visual Studio 中发布我的 .NET 应用程序。我收到一千多个这样的错误:

Unable to delete file "obj\Debug\Package\PackageTmp\Views\ViewName.svn\text-base\ActionName.aspx.svn-base". Access to the path 'C:\Code\SolutionName\ProjectName\obj\Debug\Package\PackageTmp\Views\ViewName.svn\text-base\ActionName.aspx.svn-base' is denied.

无法删除文件“obj\Debug\Package\PackageTmp\Views\ViewName.svn\text-base\ActionName.aspx.svn-base”。拒绝访问路径“C:\Code\SolutionName\ProjectName\obj\Debug\Package\PackageTmp\Views\ViewName.svn\text-base\ActionName.aspx.svn-base”。

Visual Studio: "Publish failed"

Visual Studio:“发布失败”

Why is Subversion giving me trouble? How do I fix it?

为什么 Subversion 会给我带来麻烦?我如何解决它?



I disabled the file indexing of my bin and obj folders. But, that didn't work.

我禁用了 bin 和 obj 文件夹的文件索引。但是,那没有用。

Allow files in this folder to have contents indexed in addition to file properties

允许此文件夹中的文件除文件属性外还对内容进行索引

回答by Zack Peterson

I noticed that my folders were read-only. I changed that.

我注意到我的文件夹是只读的。我改变了那个。

It worked! Publish succeeded.

有效!发布成功。

Folder Properties Read-only

文件夹属性只读

回答by Dee

I believe your issue is related to the default permissions assigned the to C: drive in windows 7 (and Vista).

我相信您的问题与 Windows 7(和 Vista)中分配给 C: 驱动器的默认权限有关。

  1. Open explorer and find the c:\code folder
  2. Right click on the c:\code folder and select properties
  3. select the security tab
  4. select the user ID "Users"
  5. In the permissions box, tick the "modify" allow box
  6. Select OK, OK until permision dialog boxes close
  1. 打开资源管理器并找到 c:\code 文件夹
  2. 右键单击 c:\code 文件夹并选择属性
  3. 选择安全选项卡
  4. 选择用户 ID“用户”
  5. 在权限框中,勾选“修改”允许框
  6. 选择确定,确定直到权限对话框关闭

That should resolve the permission issue

那应该可以解决权限问题

回答by JaredPar

The most likely cause is a permissions issue. The path in question may have been created while you were running with elevated permissions and hence requires admin permissions to delete. Try running Visual Studio as an admin and see if the problem goes away.

最可能的原因是权限问题。有问题的路径可能是在您以提升的权限运行时创建的,因此需要管理员权限才能删除。尝试以管理员身份运行 Visual Studio,看看问题是否消失。

If so then the best solution is to do the following

如果是这样,那么最好的解决方案是执行以下操作

  1. Save the changes to that directory (check in if necessary)
  2. Delete the repository
  3. Re-check out the repository and ensure you are not running as an admin when doing so
  1. 将更改保存到该目录(必要时签入)
  2. 删除存储库
  3. 重新签出存储库并确保这样做时您没有以管理员身份运行

回答by Hugo Estrada

I had this same problem, and none of the previous solutions worked. What worked for me was to take the bin and obj folders out of repository. After doing that, I was able to publish.

我遇到了同样的问题,以前的解决方案都没有奏效。对我有用的是将 bin 和 obj 文件夹从存储库中取出。这样做之后,我就可以发布了。

回答by Ray

What actually works is the solution that Zack Peterson gave? Thanks Zack!

Zack Peterson 给出的解决方案实际有效吗?谢谢扎克!

I am writing an application that will automatically remove all of the .SVNfolders and files during deployment. While doing so, I was getting the same error as described above.

我正在编写一个应用程序,它将.SVN在部署期间自动删除所有文件夹和文件。这样做时,我遇到了与上述相同的错误。

  • Once I changed the folder to NOTbe Read Only, I was able to delete files and folders programmatically.
  • My next step is to set the attribute programmatically on NOT Read Onlyso that I can accomplish the entire installation with the click of a button.
  • 有一次,我改变了文件夹只读,我可以以编程方式删除文件和文件夹。
  • 我的下一步是以编程方式在NOT Read Only上设置属性,以便我可以通过单击按钮完成整个安装。

回答by PeterX

I just deleted the existing folders at the publish destination which then allowed publishing to work. Un-setting read-only didn't seem to work. (Not sure why this started occurring).

我刚刚删除了发布目的地的现有文件夹,然后允许发布工作。取消设置只读似乎不起作用。(不知道为什么这开始发生)。

回答by Alex

Oddly enough, I tried building an old project with Visual Studio 2010. It gave me the error that it failed due to my access being denied. I tried to remove the read-only off the directory and had no luck.

奇怪的是,我尝试使用 Visual Studio 2010 构建一个旧项目。它给我的错误是由于我的访问被拒绝而失败。我试图从目录中删除只读,但没有运气。

Although, when I opened it in Visual Studio 2015, it gave me the error that my certificate was expired.

虽然,当我在 Visual Studio 2015 中打开它时,它给了我证书已过期的错误。

Upon creating a new certificate and rebuilding - everything was fine.

创建新证书并重建后 - 一切都很好。

回答by rahul

For me, the windows service was running in the background. closing the service from the task manager and then rebuilding the project did the job for me.

对我来说,windows 服务在后台运行。从任务管理器关闭服务,然后重建项目为我完成了这项工作。

回答by Janardhan Reddy

My problem resolved after doing:

执行后我的问题解决了:

  1. Close VS and Restart your machine.
  2. Update all your softwares to latest stable versions at Manage Nuget package for solution
  3. Run your test now.
  1. 关闭 VS 并重新启动您的机器。
  2. 在管理 Nuget 包中将所有软件更新到最新的稳定版本以获取解决方案
  3. 现在运行你的测试。

Hope this helps.

希望这可以帮助。

回答by Nazar

Right click on the shortcut you start the IDE from and select properties. Click advanced and click'Run as Administrator'. Worked as charm for me.

右键单击启动 IDE 的快捷方式并选择属性。单击高级,然后单击“以管理员身份运行”。对我来说很有魅力。