locked
VS2013u1 publishing occasionally get directory is not empty error RRS feed

  • Question

  • User1292358045 posted

    When I publish website to local drive through Publish Web button on VS2013 u1, I get

    Error    1    Unable to remove directory "obj\Debug\AspnetCompileMerge\TempBuildDir". The directory is not empty.


    sometimes. And some other times, I got

    2>Deleting existing files...
    2>Error deleting file 'Areas'.  Unable to delete 'Areas'.  The directory is not empty.

    at end of publishing.

    It is not a sever bug since I can reclick the button, and normally in two or three tries, it can publish web without problem.

    publishing web through MSBuild command line has no problem so far.

    Thursday, March 20, 2014 12:38 PM

Answers

All replies

  • User-166373564 posted

    Hi Cheng Bao

    Error    1    Unable to remove directory "obj\Debug\AspnetCompileMerge\TempBuildDir". The directory is not empty.

    sometimes. And some other times, I got ........

    For this issue, I’d like to suggest you to enable the failed Request Tracing in IIS, this will give me some hint on why a request has failed, we can enable this Failed Request Tracing in the IIS by steps below,

    1.Open Internet Information Services (IIS) Manager:

    2.In the Connections pane, select the server connection, site, application, or directory for which you want to configure failed request tracing.

    3.In the Actions pane, click Failed Request Tracing...

    4.In the Edit Web Site Failed Request Tracing Settings dialog box, select the Enable check box to enable tracing, leave the default value or type a new directory where you want to store failed request log files in the Directory box, type the number of failed request trace files you want to store in the Maximum number of trace files box, and then click OK.

    You can check log files in C:\inetpub\logs\FailedReqLogFiles, it will give more details to troubleshoot this issue.

    If you have any concern, please let me know.

    Regards

    Friday, March 21, 2014 2:58 AM
  • User1292358045 posted

    I don't think this problem related to IIS. since it could happen without I launching IIS Express from visual studio.
     Also, I am not publish web to remtoe IIS, I just publish web to a local directory.

    Furthermore, I am using IIS express, which doesn't comes with IIS manager

    Friday, March 21, 2014 11:51 AM
  • User-166373564 posted

    Hi Cheng

    Could you provide the procedure you done so that we can reproduce this issue?

    Best regards

    Angie Xu

    Sunday, March 23, 2014 11:33 PM
  • User1292358045 posted

    I have my solution placed in C:\Users\<user>\Documents\Visual Studio 2013\Projects\<solution>\

    and there are folders under that solution folder for each project.

    I created a web publish profile named ToLocal, and Publish Method is File System, Target Location is

    C:\Users\<user>\Documents\Visual Studio 2013\Projects\<solution>\publish,

    Configuration <Debug>, File Publish Options: Delete all existing files prior to publish checked,

    Precompile during publishing checked

          Precomplile option:

                Allow precompiled site to be updatable checked

                Emit debug information checked

                Merge options: Do not merge selected

    Exclude files from the APP_Data folder UNchecked

    Then at VS tool bar, add publish toolset, select ToLocal in profile list, click Publish Web button.

    It is highly likely to receive Error    30    Unable to remove directory "obj\Debug\AspnetCompileMerge\TempBuildDir". The directory is not empty.
    on first try, before compiling start.


    the 2nd attempt to publish is likely to end with

    1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v / -p "C:\Users\<user>\Documents\Visual Studio 2013\Projects\<solution>\<project>\obj\Debug\AspnetCompileMerge\Source" -u -d "C:\Users\<user>\Documents\Visual Studio 2013\Projects\<solution>\<project>\obj\Debug\AspnetCompileMerge\TempBuildDir"
    1>Copying all files to temporary location below for package/publish:
    1>obj\Debug\Package\PackageTmp.
    1>Deleting existing files...
    1>Error deleting file 'Controls'.  Unable to delete 'Controls'.  The directory is not empty.

    The third try is normal success, and be succeed thereafter, until several hours later, it is error again.

    type commandline MsBuild to publish is ok, I never encount problem so far, even with Visual Studio open and IIS express running on the solution

    Edit: Now I encount same error, as VS publish in commandline, while olution is open in visual studio.

    Monday, March 24, 2014 12:21 PM
  • User-166373564 posted

    HI Cheng Bao

    It is highly likely to receive Error    30    Unable to remove directory "obj\Debug\AspnetCompileMerge\TempBuildDir". The directory is not empty.
    on first try, before compiling start.

    According to this error message above, it means that web site is using directory "obj\Debug\AspnetCompileMerge\TempBuildDir", so it can't be removed.

    Here are a few suggestions that might help:

    •Clean and Rebuild: Right-click > Clean, Right-click Rebuild respective) and see if that makes any difference at all. 

    •Closing Older IIS Instances: Stop your existing application and ensure that you don't have any additional IIS processes or instances of your local Web Server running.

    •Consider Restarting Visual Studio: If these issues are still persisting after the above steps, try restarting Visual Studio (and even your local machine)

    If the issue still persists after all of them, we might try looking into a few more advanced alternatives.

    Hope it helps.

    Regards

    Thursday, March 27, 2014 2:46 AM
  • User1292358045 posted

    For tip Closing Older IIS Instances and Consider Restarting Visual Studio,

    this problem could happen and very likely happen in the morning, when I freshly enter office, start computer (cold start), start visual studio, open solution, click publish web button.

    So, the VS is freshly started, and there is no IIS instance running, but now it is mostly like I got my problem.

    And for tip Clean and Rebuild, I couldn't tell if it works, since if problem occured, normally click publish web again will solve it, so I can't tell clean and rebuild has effect or not.

    Thursday, March 27, 2014 12:05 PM
  • User1292358045 posted

    Also today morning, I start computer from cold, start VS, open solution, "Clean Build", click publish button, then I got

    Error    30    Unable to remove directory "obj\Debug\AspnetCompileMerge\TempBuildDir"

    I suspect maybe AVG some time prevent the deletion because it was scanning it? I will try to disable AVG for now to see if it happens again

    Friday, March 28, 2014 12:03 PM
  • User1292358045 posted

    Ok, I disabled AVG, still I got

    1>Copying all files to temporary location below for package/publish:
    1>obj\Debug\Package\PackageTmp.
    1>Deleting existing files...
    1>Error deleting file 'Service References'.  Unable to delete 'Service References'.  The directory is not empty.

    Friday, March 28, 2014 12:24 PM
  • User-166373564 posted

    Hi Cheng Bao

    First restores the IDE's default settings using this command line: Devenv.exe/ResetSettings;

    Second deploy a Web Project Using One-Click Publish in Visual Studio, here is the reference: http://msdn.microsoft.com/en-us/library/dd465337.aspx 

    Here are more deployment strategies in the link below:

    ASP.NET Web Application Project Deployment Overview

    http://msdn.microsoft.com/en-us/library/dd394698%28v=VS.100%29.aspx

    If the issue still persists after all of them, you might try looking into a few more advanced alternatives.

    Best regards

    Angie Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 31, 2014 11:15 PM
  • User1070236303 posted

    I also got similar directory not empty errors. The directories are random.

    Just at the moment got "Cannot delete Content because its is not empty. Publish failed". But the Content folder becomes empty after the failed publish attempt, but vs 2013 just leaves it there. Usually a second publish attempt works.

    I'm sure that this is a bug in vs 2013.

    /I'm using vs 2013 built-in publish ("one-click publish"), delete all existing files prior to publish is checked./

    Wednesday, April 9, 2014 5:01 AM
  • User1292358045 posted

    Actually, with more testing, I think this issue is not isolated to VS 2013.

    With VS2013 not running, and MSBuild commandline to publish website, I encounters same problem once. Although to me, the probabilty that I encounter this error is much higher in VS than command line.

    Wednesday, April 9, 2014 5:48 PM