Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
MSBuild Reference
 Delete Task

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework General Reference
Delete Task

Deletes the specified files.

The following table describes the parameters of the Delete task.

Parameter

Description

DeletedFiles

Optional ITaskItem[] output parameter.

Specifies the files that were successfully deleted.

Files

Required ITaskItem[] parameter.

Specifies the files to delete.

TreatErrorsAsWarnings

Optional Boolean parameter

If true, errors are logged as warnings. The defalut value is false.

The following example deletes the file MyApp.pdb.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
        <AppName>MyApp</AppName>
    </PropertyGroup>

    <Target Name="DeleteFiles">
        <Delete Files="$(AppName).pdb" />
    </Target>
</Project>

Concepts

Other Resources

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Wildcards and conditions      Skywise   |   Edit   |   Show History
Note that you cannot use wilcards - it needs specific file names.

Also, note that you can use Conditions, e.g.:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<AppName>MyApp</AppName>
</PropertyGroup>

<Target Name="DeleteFiles">
<Delete
Files="$(AppName).pdb"

Condition="Exists=('$(AppName).pdb')"

/>
</Target>
</Project>
Tags What's this?: Add a tag
Flag as ContentBug
uses "del" command, with its limitations      Steve Nuchia   |   Edit   |   Show History
Apparently the Delete task wraps a "del" command line. This means it can't delete read-only files. Major PITA.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker