[Source: http://geekswithblogs.net/EltonStoneman]
One of the nice advantages of developing on a virtual image is that you can set it up with one drive for the OS and another for data. Your dev toolset is ready for project joiners to use, and copying a 15Gb file is far quicker than installing your toolset from nothing. When you want to take work home or on the train with you, it's just a case of zipping up the 1Gb data drive and copying it to your laptop.
I've been doing this using Microsoft Virtual PC once or twice a day for the last few months, and it's somewhere like 99.99% faultless. But that 0.01% fault is manifested as random files being reduced to zero-bytes. They have the correct name and are in the expected location, but are missing their contents. So suddenly a project fails to build as one of the class files is empty.
This seems to be a result of occasionally resizing the .vhd file, rather than with repeatedly zipping and unzipping it. I haven't got an answer for the cause, but the following PowerShell script will output all the zero-length files you have on disk:
##FindZeroByteFiles.ps1
param([string[]] $paths)
function Main
{
foreach ($path in $paths) {
$list = Join-Path $path zeros.txt
Remove-Item $list -ErrorAction SilentlyContinue
get-childitem $path -recurse | sort Length | foreach {
if ($_.Length -eq 0) {
$_.FullName >> $list
}
}
}
}
. Main
##
Usage – to list all the zero byte files on drives F and G:
.\FindZeroByteFiles.ps1 F:\,G:\
This will output a file called zeros.txt in the root of each drive specified.
I'll be running it more frequently and I'll update this post if I track down which part of the process is mangling those files in the virtual drive. Or if I get around to writing a heftier script which compares two virtual drives using VHDMount.