This topic applies to: ✓ .NET Core 1.x .NET Core 2.x


dotnet clean - Cleans the output of a project.


dotnet clean [<PROJECT>] [-c|--configuration] [-f|--framework] [-o|--output] [-r|--runtime] [-v|--verbosity]
dotnet clean [-h|--help]


The dotnet clean command cleans the output of the previous build. It's implemented as an MSBuild target, so the project is evaluated when the command is run. Only the outputs created during the build are cleaned. Both intermediate (obj) and final output (bin) folders are cleaned.



The MSBuild project to clean. If a project file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj and uses that file.


-c|--configuration {Debug|Release}

Defines the build configuration. The default value is Debug. This option is only required when cleaning if you specified it during build time.

-f|--framework <FRAMEWORK>

The framework that was specified at build time. The framework must be defined in the project file. If you specified the framework at build time, you must specify the framework when cleaning.


Prints out a short help for the command.

-o|--output <OUTPUT_DIRECTORY>

Directory in which the build outputs are placed. Specify the -f|--framework <FRAMEWORK> switch with the output directory switch if you specified the framework when the project was built.


Cleans the output folder of the specified runtime. This is used when a self-contained deployment was created.

-v|--verbosity <LEVEL>

Sets the verbosity level of the command. Allowed levels are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].


Clean a default build of the project:

dotnet clean

Clean a project built using the Release configuration:

dotnet clean --configuration Release