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

后端 未结 26 1957
迷失自我
迷失自我 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:53

    I use a slight modification of Robert H which skips errors and prints the delete files. I usally also clear the .vs, _resharper and package folders:

    Get-ChildItem -include bin,obj,packages,'_ReSharper.Caches','.vs' -Force -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse -ErrorAction SilentlyContinue -Verbose}
    

    Also worth to note is the git command which clears all changes inclusive ignored files and directories:

    git clean -dfx
    
    0 讨论(0)
  • Is 'clean' not good enough? Note that you can call msbuild with /t:clean from the command-line.

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

    This Works Fine For Me: start for /d /r . %%d in (bin,obj, ClientBin,Generated_Code) do @if exist "%%d" rd /s /q "%%d"

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

    This worked for me:

    for /d /r . %%d in (bin,obj) do @if exist "%%d" rd /s/q "%%d"
    

    Based on this answer on superuser.com

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

    I think you can right click to your solution/project and click "Clean" button.

    As far as I remember it was working like that. I don't have my VS.NET with me now so can't test it.

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

    To delete bin and obj before build add to project file:

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

    Here is article: How to remove bin and/or obj folder before the build or deploy

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