如何在 Visual Studio 中完全清理 bin 和 obj 文件夹? [英] How to fully clean bin and obj folders within Visual Studio?

查看:39
本文介绍了如何在 Visual Studio 中完全清理 bin 和 obj 文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您右键单击一个文件夹,您将看到一个清理"菜单项.我认为这会清理(删除) obj 和 bin 目录.但是,据我所知,它什么也没做.还有其他方法吗?(请不要告诉我去 Windows Explorer 或 cmd.exe)我想删除 obj 和 bin 文件夹,以便我可以轻松地压缩整个文件.

If you right click on a folder, you will see a "Clean" menu item. I assumed this would clean (remove) the obj and bin directory. However, as far as I can see, it does nothing. Is there another way? (please don't tell me to go to Windows Explorer or the cmd.exe) I'd like to remove the obj and bin folder so that I can easily zip the whole thing.

推荐答案

正如其他人已经响应的那样,Clean 将删除构建生成的所有工件.但它会抛开其他一切.

As others have responded already Clean will remove all artifacts that are generated by the build. But it will leave behind everything else.

如果您在 MSBuild 项目中有一些自定义设置,这可能会带来麻烦并留下您认为应该删除的内容.

If you have some customizations in your MSBuild project this could spell trouble and leave behind stuff you would think it should have deleted.

您可以通过简单地更改您的 .*proj 来规避这个问题,方法是在接近末尾的某处添加它:

You can circumvent this problem with a simple change to your .*proj by adding this somewhere near the end :

<Target Name="SpicNSpan"
        AfterTargets="Clean">
    <RemoveDir Directories="$(OUTDIR)"/>
</Target>

这将删除当前平台/配置的 bin 文件夹中的所有内容.

Which will remove everything in your bin folder of the current platform/configuration.

------ 编辑基于以下萨满的回答的轻微演变(分享投票并给他一些)

------ Edit Slight evolution based on Shaman's answer below (share the votes and give him some too)

<Target Name="SpicNSpan"  AfterTargets="Clean">
    <!-- Remove obj folder -->
    <RemoveDir Directories="$(BaseIntermediateOutputPath)" />
    <!-- Remove bin folder -->
    <RemoveDir Directories="$(BaseOutputPath)" />
</Target>

---- 使用 xDisruptor 中的部分再次编辑,但我删除了 .vs 删除,因为这样会更好在 .gitignore (或等效)中

---- Edit again with parts from xDisruptor but I removed the .vs deletion as this would be better served in a .gitignore (or equivalent)

为 VS 2015 更新.

Updated for VS 2015.

<Target Name="SpicNSpan" AfterTargets="Clean"> <!-- common vars https://msdn.microsoft.com/en-us/library/c02as0cs.aspx?f=255&MSPPError=-2147217396 -->
     <RemoveDir Directories="$(TargetDir)" /> <!-- bin -->
     <RemoveDir Directories="$(ProjectDir)$(BaseIntermediateOutputPath)" /> <!-- obj -->
</Target>

如果您有多个项目要推进,他还提供了一个很好的建议,使任务更易于部署和维护.

He also provides a good suggestion on making the task easier to deploy and maintain if you have multiple projects to push this into.

如果您对此答案投票,请务必同时投票.

If you vote this answer be sure to vote them both as well.

这篇关于如何在 Visual Studio 中完全清理 bin 和 obj 文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆