Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:48:22+00:00 2026-05-29T05:48:22+00:00

I am using MSBuild and have a Delete task that deletes all the files

  • 0

I am using MSBuild and have a Delete task that deletes all the files under a directory. The next task cleans out the directory of any folder by using RemoveDir. I have a timing issue where the directory isn’t always completely clean of files from the Delete command before the RemoveDir command runs. Happens about half the time, and when it does the script errors out, b/c the RemoveDir can’t remove directories for which files exist in them.

Can someone help me with a way to fix this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:48:23+00:00Added an answer on May 29, 2026 at 5:48 am

    Make sure you are calling the RemoveDir task after the Delete action has been run by using DependsOnTargets:

    <Target Name="RemoveDirectories" DependsOnTargets="DeleteFiles">
      <RemoveDir Directories="@(DirsToRemove)" />
    </Target>
    

    However it’s probable that timing is not the real issue here. The issue may be that DeleteFiles fails to delete some locked or read-only files, which as a result fails the RemoveDir task to complete.
    In this case consider using MSBuild Extension Pack’s Folder class which can forcefully remove all files.

    <MSBuild.ExtensionPack.FileSystem.Folder TaskAction="RemoveContent" Path="@(DirsToRemove)" Force="true" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WIX file that I need to modify using MSBuild. It starts
I am using TeamCity to run an MSBuild script that cleans and rebuilds one
I have been using a msbuild file that builds and packages my solution to
Does anyone have a good way to build MSI (vdproj) projects using MsBuild or
I would like to publish a website using msbuild. Since I have a website
I am using Team City as the build server, and I have a msbuild
I have a project that currently compiles happily on my dev machine using VS
In my msbuild script I have to clean a directory, which has some hidden
We have a batch-based buildprocess and we are using MSBuild only for compiling our
Is there a way that I can have different directory names per installation of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.