visual-studio 在 Visual Studio 中,“Clean”命令有什么作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1603242/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:07:47  来源:igfitidea点击:

In Visual Studio, what does the "Clean" command do?

visual-studiobuild-process

提问by Arnis Lapsa

You know, the one that outputs this=>

你知道,输出这个=>

------ Clean started: Project: Foo.Bar, Configuration: Debug Any CPU ------
========== Clean: 1 succeeded, 0 failed, 0 skipped ==========

------ 清洁开始:项目:Foo.Bar,配置:调试任何 CPU ------
========== 清洁:1 成功,0 失败,0 跳过 ==== ======

What it is cleaning?

什么是清洁?

回答by Jon Skeet

The output directories - it removes the code that it's previously built.

输出目录 - 它删除了之前构建的代码。

It doesn't remove the bin/obj directories themselves (or the Debug/Release directories beneath them), just the actual .exe, .dll, etc files. Unfortunately this makes it less useful for my usual use of cleaning up output directories: when I want to zip up the source code. As the Clean action doesn't do this, I usually just delete the bin and obj directories directly.

它不会删除 bin/obj 目录本身(或它们下面的 Debug/Release 目录),只会删除实际的 .exe、.dll 等文件。不幸的是,这对于我通常用于清理输出目录的用途来说不太有用:当我想压缩源代码时。由于 Clean 操作不这样做,我通常只是直接删除 bin 和 obj 目录。

回答by Richard Berg

Why not look for yourself? Open up Microsoft.Common.Targets (found under %windir%\Microsoft.NET) and you'll see a section like so:

为什么不自己找呢?打开 Microsoft.Common.Targets(位于 %windir%\Microsoft.NET 下),您将看到如下所示的部分:

<!--
============================================================
                                    Clean

Delete all intermediate and final build outputs.
============================================================
-->
<PropertyGroup>
    <CleanDependsOn>
        BeforeClean;
        CleanReferencedProjects;
        UnmanagedUnregistration;
        CoreClean;
        CleanPublishFolder;
        AfterClean
    </CleanDependsOn>
</PropertyGroup>
<Target
    Name="Clean"
    Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
    DependsOnTargets="$(CleanDependsOn)" />

Keep reading to see exactly what each of those sub-targets does. (Some, of course, are just stubs for the user to override).

继续阅读以确切了解每个子目标的作用。(当然,有些只是供用户覆盖的存根)。

Personally, I like to see what shenanigans my fancy-pants IDE is up to behind my back. To this end, I'd recommend increasing the amount of info written to the Output window. Tools -> Options -> Projects & Solutions -> Build & Run -> MSBuild verbosity -> change from "Minimal" to "Normal" or "Detailed."

就我个人而言,我喜欢看看我的花哨的 IDE 在我背后做了什么恶作剧。为此,我建议增加写入输出窗口的信息量。工具 -> 选项 -> 项目和解决方案 -> 构建和运行 -> MSBuild 详细程度 -> 从“最小”更改为“正常”或“详细”。

Try your Clean operation again and watch the output now! Correlating what you see to the *.targets files is a good way to start learning MSBuild.

再次尝试您的 Clean 操作并立即观察输出!将您看到的内容与 *.targets 文件相关联是开始学习 MSBuild 的好方法。

回答by Joseph

It goes through your output directories and deletes any build related files in them.

它遍历您的输出目录并删除其中的任何与构建相关的文件。

I think you can also configure this by going to the Project's properties in

我认为您也可以通过转到项目的属性来配置它

Configuration Properties -> General, under "Extensions to Delete on Clean"

配置属性 -> 常规,在“清理时删除的扩展”下

回答by vehomzzz

removes all the files associated with the build, output directories

删除与构建、输出目录相关的所有文件

回答by Adam Casey

People use a 'clean' to force a complete rebuild from source. Your compiler doesn't rebuild every file every time if it hasn't changed.

人们使用“干净”来强制从源头完全重建。如果没有更改,您的编译器不会每次都重建每个文件。