在專案.csproj檔新增
<Project>
...
<!-- #region 清理 bin 和 obj 資料夾 -->
<Target Name="CleanBinObjFolders" AfterTargets="Clean">
<!-- Remove obj folder -->
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
<!-- Remove bin folder -->
<RemoveDir Directories="$(BaseOutputPath)" />
</Target>
<!-- #endregion -->
</Project>
參考來源:How to fully clean bin and obj folders within Visual Studio?