views:

674

answers:

5

You know, the one that outputs this=>

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

What it is cleaning?

+5  A: 

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.

Jon Skeet
Good point about not removing the directories entirely. Its mostly moot for me because Subversion has the export command that works well (at least if you haven't added the bin, obj, *.suo, *.user, etc. files to the repository that is). But, yeah, it would be nice to see that feature.
Brian Gideon
+5  A: 

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"

Joseph
sry, Jon was 1st. :)
Arnis L.
np, need faster fingers =P
Joseph
I'm quite sure i knew this. Just haven't find a good use case for it and therefore - forgot. Couldn't understand how to ask it properly to google.
Arnis L.
+2  A: 

removes all the files associated with the build, output directories

vehomzzz
+2  A: 

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.

Adam Casey
+4  A: 

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

<!--
============================================================
                                    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."

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.

Richard Berg
Nice stuff. Despite that i'm more interested how NAnt works.
Arnis L.
+1 for MSBuild Verbosity. :)
Scott Ferguson