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

12

23

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

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

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.

Visual Studio: "Publish failed"

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


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

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

Armillda answered 2/9, 2010 at 14:57 Comment(2)
And since you're using Win7, also have a look at this article here.Giblet
I ran into the same error messages, but for a different reason. I was making a change to a WCF project, and at some point in the past I had installed the executable in the debug folder as a Windows Service, which was still running.Kennie
A
48

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

It worked! Publish succeeded.

Folder Properties Read-only

Armillda answered 2/9, 2010 at 19:50 Comment(5)
AFAIK Just was a permission issues, Try to set elevated permissions on shared folders but targeting machines, cause otherwise when you use users it wouldn't workShakira
I had this problem and this was the fix for me. It was not on the computer the files originated, but one that had done a full get of the project.Knorr
Fixed for me as well, I wonder why these were read only by default.Legofmutton
Saved my day ! Thanks. Still wondering how it became a read-only folder..Liba
This is still a situation in 2020, for some reasons the bin\roslyn folder is read only, trying to delete it wouldn't work, couldn't take ownership of the directory either (as SA). I Guess: IIS makes the folder Read Only while the App Pool is running to prevent malicious activity against certain libraries.Fillagree
M
5

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

  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

That should resolve the permission issue

Maldives answered 2/9, 2010 at 16:19 Comment(1)
Thanks. I changed the folder settings. But, that didn't work.Armillda
P
4

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.

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
Parsimonious answered 2/9, 2010 at 15:0 Comment(3)
Thanks. I tried running Visual Studio as an administrator. But, that didn't work.Armillda
Thanks. I recreaded the folder fresh from the Subversion server. But, that didn't work.Armillda
@Zack, then that suggests something has the filed opened with non-sharable permissions. Try using handle.exe to see who's holding it open.Parsimonious
F
4

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.

Fiji answered 10/11, 2010 at 15:48 Comment(0)
M
1

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

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

  • Once I changed the folder to NOT be Read Only, I was able to delete files and folders programmatically.
  • My next step is to set the attribute programmatically on NOT Read Only so that I can accomplish the entire installation with the click of a button.
Mirellamirelle answered 19/1, 2011 at 22:20 Comment(0)
M
1

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).

Mornings answered 15/5, 2012 at 1:30 Comment(0)
U
1

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.

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

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

Uncoil answered 29/6, 2016 at 18:19 Comment(0)
R
1

If you are being denied access to any specific folder, then it is being used by some other application.Check if any other application is using that path to reference that folder of any file in that folder. In my case , my application was reference a file inside the bin folder. So every time i publish and delete the old one. error will be thrown that bin folder can not be deleted. access denied. i went in my application. checked in the refrenced path of each dll, removed the ones which referenced the publish path and BOOM Issue solved.

Ratoon answered 31/10, 2016 at 15:31 Comment(0)
M
1

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.

Micturition answered 6/11, 2017 at 19:35 Comment(0)
V
0

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.

Hope this helps.

Valerle answered 23/7, 2019 at 10:6 Comment(0)
F
0

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.

Fib answered 16/3, 2020 at 11:29 Comment(0)
L
0

Open Task Manager, find explorer, end task, run new task, type explorer and voila! this works in my case

Liquidation answered 22/3 at 9:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.