dotnetpublish:清理外部输出目录

Ped*_*rez 10 .net-core dotnet-cli

我想在发布之前清理我的外部输出文件夹。我今天得到的解决方案如下:

Remove-Item -Path ..\artifacts -ErrorAction SilentlyContinue -Recurse -Force;
dotnet publish ..\myproject.sln -c Release -o ..\artifacts\myproject;
Run Code Online (Sandbox Code Playgroud)

有没有更好的方法来做到这一点(没有Remove-Item)?我尝试使用dotnet clean并指定输出文件夹,但不起作用。