TFS 2010 Build Failed - Access to the path ... is denied


  • I am in the process of configuring TFS 2010 for a ASP.NET website (4.0).  Unfortunately, I am encountering a lot of difficulty getting an automated build to successfully deploy our web application to the appropriate locations.  Our web application is distributed across multiple servers (load balanced) so after the build agent builds the web site I added "DeleteDirectory" and "CopyDirectory" Team Foundation Build Activities to copy the appropriate folder to the locations where our web site is configured.  Everything runs fine until the DeleteDirectory activity occurs and the error "Access to the path ... is denied" fails the build.

    The build agent is configured to login as an account registered in Active Directory which has Full Permissions to the folders which we're asking it to Delete and Copy to.  I've even recently granted Administration access to that user to help rule out missing some simple mistake.  If I log in as the user the service uses on the server in question and attempt to delete the folder specified in the DeleteDirectory activity it does so without an issue.  I have no idea why the build agent is unable to perform this step.  Any thoughts?

    The process template (A slightly edited version of the Default process template... I didn't want the build process to create work items on build failures) DeleteDirectory activity code is below:

    <mtbwa:DeleteDirectory Directory="\\servername\d$\WebsiteRoot\ProjectName 2.0 Website\Project" sap:VirtualizedContainerService.HintSize="1384,22" />

    The specific entries from the failed log file are below:


    Initial Property Values
    Directory = \\servername\d$\WebsiteRoot\ProjectName 2.0 Website\Project
    Recursive = True

    Final Property Values
    Directory = \\servername\d$\WebsiteRoot\ProjectName 2.0 Website\Project
    Recursive = True

    Access to the path '\\servername\d$\WebsiteRoot\ProjectName 2.0 Website\Project' is denied.

    Any thoughts whatsoever?  This has me completely puzzled.

    • Edited by RudyW Saturday, December 04, 2010 9:00 PM readability
    Saturday, December 04, 2010 8:23 PM

All replies

  • Have you tried to log on to the build agent with the build service account and access the network path from there? Does this work?


    Blog: http://geekswithblogs.net/jakob Twitter: http://twitter.com/osirisjakob
    Sunday, December 05, 2010 7:32 PM
  • Hi Jakob,

    Thanks for responding.  If I understand your question to be that you want me to login to the server where the build agent runs (While troubleshooting I only have 1 active build agent running) and attempt to access the network path and delete the folder then the answer is "yes, it works perfectly fine."

    While trying to reduce the number of variables in play here, I am having the DeleteDirectory activity attempt to delete a folder on the same machine as the build agent.  Also, just for the heck of it I decided to login to another machine using the same AD account which the build service uses and attempt to delete the same folder via the network path from this other machine.  That worked too.  Argh!


    Sunday, December 05, 2010 7:53 PM
  • The problem can really only be one of two things:

    1. The build service account does not have enough permission
    2. The directory that you are trying to delete is in use by some process

    It seems that you have ruled out the first one, so probably the problem is that some process is locking something in the directory.



    Blog: http://geekswithblogs.net/jakob Twitter: http://twitter.com/osirisjakob
    Sunday, December 05, 2010 9:40 PM
  • One would seem those are the only two options... However, I don't know what more I could do to prove both of those are not related to my problem...  So this morning I added a new folder to the server which isn't used by anything.  I then created a subfolder under this new parent folder and shared the parent folder.  I didn't use any special characters in this share name like the existing example where a "$" is used.  My goal was to delete this unused subfolder.  Failed. Same error.

    Again, the build service user is identified as an Administrator on the machine. The folder which we're trying to delete is on the same server. The folder is empty.  Somebody give me an idea of something to look at.  ;) I'm really running out of ideas as to what could even possibly be going on here.

    I may owe somebody a virtual beer if/after we ever figure this out!


    Monday, December 06, 2010 1:38 PM
  • An update... I changed the TFS build controller AND the build agents to use my own AD credentials (and restarted them) and I still receive this error.  So very very odd...  And yes, I definitely have access as I created the test folders I am attempting to delete.  I also tried using the CreateDirectory activity which fails with the same result.

    Monday, December 06, 2010 7:34 PM
  • All,

    If any of you in the future read this post and are having a similar frustration you may not need the "DeleteDirectory" activity at all.  In my case I assumed I needed to delete the destination directory before the CopyDirectory activity.  Not necessary.  The CopyDirectory will overwrite any files without issue.  However, if you desire files no longer in your project to be removed I haven't confirmed if CopyDirectory will ignore those files thus potentially leaving unwanted files in your destination folder.

    The issue with the DeleteDirectory and CreateDirectory activities still exists, but for my specific needs I don't need to even use them in my build process template.


    Thursday, December 09, 2010 12:57 PM
  • I have also run into the same problem. I can log into the machine and delete the files manually without any problem but TFS build which runs under the same account will fail repeatedly trying to delete it.

    Tuesday, May 17, 2011 8:34 PM
  • Hi LindseyL,

    We were never able to identify the permissions issue produced by the DELETE action.  However, we bypassed the issue by using the CopyDirectory action without attempting to DELETE the directory first.  The CopyDirectory simply overwrites any existing files.  This approach will result in old/unused files staying in the target directory...

    Tuesday, May 24, 2011 12:21 PM
  • Hi Folks,

    I am having the same issue. This is really lame. I have the build controller and the build agent running as a domain account. That account has full control to the directory. But I get the access denied when trying to publish files to the directory. I'm not even trying to delete, just copy files up to the folder. And the folder is empty... :(

    Well, I will keep trying and post back if I find an answer.



    Tuesday, May 24, 2011 10:43 PM
  • Hi,

    I'm facing similar "Access denied" issue. The issue is with automated builds, While creating workspace and getting workspace, all files are getting locked by TFS. "Get Workspace" shouldn't lock Files. Any idea on this?



    Wednesday, December 07, 2011 6:04 AM
  • For future reference if anyone ends up here and searches answer to the question.

    This is answered under a different topic and it worked for me. I had forgotten to give NTFS permissions to the service account doing the build and copying/deleting/creating on this location on test/stage location and only had given Share permissions which was not enough.

    Topic that helped me: http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/9ddcf888-cff8-4b59-a085-f0eed75d160c

    One more thought about analyzing the situation. Access Denied errors and login issues can be seen on the target server by investigating the Security Event Logs with Event Viewer.


    Monday, March 26, 2012 9:11 AM
  • Hi,

    Just try change your build process template, pass at MSBuildArguments field the following parameter: /p:BuildInParallel=false.

    The field MSBuildArguments is in Proccess / Advanced at the build process template editor

    Wednesday, May 28, 2014 2:31 PM