I want to delete all bin and obj folders to force all projects to rebuild everything

后端 未结 26 2011
迷失自我
迷失自我 2020-11-28 16:53

I work with multiple projects, and I want to recursively delete all folders with the name \'bin\' or \'obj\' that way I am sure that all projects will rebuild everything (so

相关标签:
26条回答
  • 2020-11-28 17:41

    Considering the PS1 file is present in the currentFolder (the folder within which you need to delete bin and obj folders)

    $currentPath = $MyInvocation.MyCommand.Path
    $currentFolder = Split-Path $currentPath
    
    Get-ChildItem $currentFolder -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
    
    0 讨论(0)
  • 2020-11-28 17:42

    from Using Windows PowerShell to remove obj, bin and ReSharper folders

    very similar to Robert H answer with shorter syntax

    1. run powershell
    2. cd(change dir) to root of your project folder
    3. paste and run below script

      dir .\ -include bin,obj,resharper* -recurse | foreach($) { rd $_.fullname –Recurse –Force}

    0 讨论(0)
  • 2020-11-28 17:42

    Here is the answer I gave to a similar question, Simple, easy, works pretty good and does not require anything else than what you already have with Visual Studio.

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

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

    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>
    

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

    0 讨论(0)
  • 2020-11-28 17:43

    Nothing worked for me. I needed to delete all files in bin and obj folders for debug and release. My solution:

    1.Right click project, unload, right click again edit, go to bottom

    2.Insert

    <Target Name="DeleteBinObjFolders" BeforeTargets="Clean">
      <RemoveDir Directories="..\..\Publish" />
      <RemoveDir Directories=".\bin" />
      <RemoveDir Directories="$(BaseIntermediateOutputPath)" />
    </Target>
    

    3. Save, reload project, right click clean and presto.

    0 讨论(0)
  • 2020-11-28 17:43

    You could actually take the PS suggestion a little further and create a vbs file in the project directory like this:

    Option Explicit
    Dim oShell, appCmd
    Set oShell  = CreateObject("WScript.Shell")
    appCmd      = "powershell -noexit Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse -WhatIf }"
    oShell.Run appCmd, 4, false
    

    For safety, I have included -WhatIf parameter, so remove it if you are satisfied with the list on the first run.

    0 讨论(0)
  • 2020-11-28 17:44

    We have a large .SLN files with many project files. I started the policy of having a "ViewLocal" directory where all non-sourcecontrolled files are located. Inside that directory is an 'Inter' and an 'Out' directory. For the intermediate files, and the output files, respectively.

    This obviously makes it easy to just go to your 'viewlocal' directory and do a simple delete, to get rid of everything.

    Before you spent time figuring out a way to work around this with scripts, you might think about setting up something similar.

    I won't lie though, maintaining such a setup in a large organization has proved....interesting. Especially when you use technologies such as QT that like to process files and create non-sourcecontrolled source files. But that is a whole OTHER story!

    0 讨论(0)
提交回复
热议问题