Search code examples
.net-coreprojectcsprojdotnet-cli

What command can I use to remove a project in .NET Core?


What command can I use to remove a project in .NET Core?

The project I want to remove was created with the help of the command:

dotnet new webapi

Is it true that there is still no command for this? It was pointed out here.


Solution

  • When you run the command dotnet new [type], dotnet will create a project in whatever folder the current working directory is. (where [type] will be something like console or webapi)

    You never want to run this command without first creating a sub-directory and changing to it or you will have a mess of files sitting somewhere you will wish they weren't. The amount of files and their names will depend on the type of project you are making.

    If you make this mistake and don't know which files to delete, you can delete them individually.

    1. Create a temporary directory and change to it.
    2. Run the same dotnet new [type] command in that directory.
    3. Looking at the files created in step #2, you will know what to delete.

    If you made a sub-directory to begin with, you can simply:

    • (windows)rd /s /q <dirname>
    • (linux)rm -rf <dirname>

    to clean up the mess.