Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically delete Test Results

I run tests several times a day in Visual Studio 2012. I recently found that my disk space was very low. I found that the test results folder in my project was using 60 GB. I deleted the files, but I want to keep it from happening. I did a search for how to do this, but all I can find are solutions for 2008 and 2010. They stated I need to make some changes to the test tools in the options. I can't find this inside of my options. How can I keep from these files appearing, or keep them to a minimal?

like image 453
Dan Burgener Avatar asked Jul 02 '13 19:07

Dan Burgener


1 Answers

Mark Seemann suggests extending the Clean target

Add this after the Import element at the end of the project file:

<PropertyGroup>
    <TestResultsFolderPath>..\TestResults</TestResultsFolderPath>
</PropertyGroup>
<Target Name="AfterClean">
    <RemoveDir Directories="$(TestResultsFolderPath)" Condition="Exists('$(TestResultsFolderPath)')" />
</Target>

Then whenever you want to manually remove the test results, you can just right-click in the Solution explorer and select Clean.

You can also achieve the same from the command line with the following

MSBuild /t:Clean MyProject.csproj

which can be scheduled if you want an automatic deletion once a week or whatever. As Mark points out, one nice feature of this approach is that you can control the deletion on a project by project basis.

like image 150
shamp00 Avatar answered Sep 28 '22 11:09

shamp00