Clean and Build a solution without using Visual Studio

Viewed 615

How can I perform these 2 tasks without opening Visual Studio:

  1. Clean a Solution.
  2. Build a Solution.

The Solution may be using .NET Standard and/or .NET Core.

Note: I want to create a batch file in (Windows cmd or PowerShell) to perform these tasks. I may not know if the Solution is using .NET Standard or .NET Core or both.

2 Answers

For .net core you can use docs

dotnet clean 

For msbuild, you can create a target Clean and then call this target from the commandline: docs

 <Target Name = "Clean">
    <RemoveDir Directories="$(builtdir)" />
</Target>

msbuild <file name>.proj -target:Clean
Related