Cleaning out temporary ASPNET files with Octopus Deploy
Running out of disk seems to be a recurrent thing for us, in particular in our Build and Edge environment. We really should add more disk, but we should also find a solution to the main problem- the increasing disk usage.
After using WinDirStat to analyze disk usage I noticed that the Temporary ASP.NET files directory seems to be taking a lot of disk on our Build and Edge machine.
![temporary-asp-net-files](https://inlovewithcode.azureedge.net/wp-content/uploads/2018/04/temporary-asp-net-files.jpg)
We use Octopus deploy for our deployment pipelines and there is a community template that you can use to clear out the files. I added the step to our process but made sure to only apply this step in Build, EDGE, QA and AT- and not PROD environments as I don’t want to trigger an unintentional app pool recycling.
![temporary-asp-net-files2](https://inlovewithcode.azureedge.net/wp-content/uploads/2018/04/temporary-asp-net-files2.jpg)
![temporary-asp-net-files4](https://inlovewithcode.azureedge.net/wp-content/uploads/2018/04/temporary-asp-net-files4.jpg)
![temporary-asp-net-files3](https://inlovewithcode.azureedge.net/wp-content/uploads/2018/04/temporary-asp-net-files3.jpg)
The first time I ran the step in EDGE it took quite a while (5 minutes) as we had a lot of cleaning up to do, but subsequent cleaning will take less time.
![temporary-asp-net-files5](https://inlovewithcode.azureedge.net/wp-content/uploads/2018/04/temporary-asp-net-files5.jpg)
I also put together a little script to check the size of the framework folders, and from Tasks- Script console in Octopus deploy I can run the script on all the machines and see if the ASP folder is a problem.
cd "C:\Windows\Microsoft.NET\Framework64"
$frameworkDirs = ls
$frameworkDirs | % {
$size = [math]::Round((Get-Childitem $_ –file –recurse | Measure-Object -Sum Length).Sum / 1GB,2)
echo "Directory size for $_ : $size GB"
}
![temporary-asp-net-files6](https://inlovewithcode.azureedge.net/wp-content/uploads/2018/04/temporary-asp-net-files6.jpg)
And to check the size of Octopus deploy packages:
$size = [math]::Round((Get-Childitem C:\Octopus\Applications –file –recurse | Measure-Object -Sum Length).Sum / 1GB,2)
echo "Directory size for Octopus: $size GB"
Turns out we hadn’t set a retention policy for AT and had accumulated shitloads of release packages hehe. I set the retention policy (this is done under lifecycle) to 3 and created and deployed a new release.
To get the disk space on all the machines I ran the following in the script console:
gwmi win32_logicaldisk | Format-Table DeviceId, MediaType, @{n="Size";e={[math]::Round($_.Size/1GB,2)}},@{n="FreeSpace";e={[math]::Round($_.FreeSpace/1GB,2)}}
Comments
Last modified on 2018-04-23