Visual Studio Publish Failed: "Unable to delete file ... Access to the path ... is denied."
Solution 1
I noticed that my folders were read-only. I changed that.
It worked! Publish succeeded.
Solution 2
I believe your issue is related to the default permissions assigned the to C: drive in windows 7 (and Vista).
- Open explorer and find the c:\code folder
- Right click on the c:\code folder and select properties
- select the security tab
- select the user ID "Users"
- In the permissions box, tick the "modify" allow box
- Select OK, OK until permision dialog boxes close
That should resolve the permission issue
Solution 3
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
- Save the changes to that directory (check in if necessary)
- Delete the repository
- Re-check out the repository and ensure you are not running as an admin when doing so
Solution 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.
Solution 5
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.
Zack Peterson
Specializes in the design and creation of web and desktop applications. Contributes in all aspects of the software development process such as: requirements analysis and product definition; prototyping; choosing architecture and framework; interface design; database design; installation and integration; documentation and training; gathering feedback; and maintenance.
Updated on July 03, 2020Comments
-
Zack Peterson almost 4 years
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.
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.
-
Zack Peterson over 13 yearsThanks. I changed the folder settings. But, that didn't work.
-
Zack Peterson over 13 yearsThanks. I tried running Visual Studio as an administrator. But, that didn't work.
-
Zack Peterson over 13 yearsThanks. I recreaded the folder fresh from the Subversion server. But, that didn't work.
-
JaredPar over 13 years@Zack, then that suggests something has the filed opened with non-sharable permissions. Try using handle.exe to see who's holding it open.
-
Jonathan Escobedo over 13 yearsAFAIK 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 work
-
BarrettJ over 13 yearsI 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.
-
MetaGuru almost 13 yearsFixed for me as well, I wonder why these were read only by default.
-
kbonnelly almost 6 yearsSaved my day ! Thanks. Still wondering how it became a read-only folder..
-
Richard about 4 yearsThis 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.