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

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

问题描述

如果右键单击文件夹,将看到清洁"菜单项.我以为这将清理(删除)obj和bin目录. 但是,据我所知,它什么也没做. 还有另一种方法吗? (请不要告诉我转到Windows资源管理器或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天全站免登陆