private void SaveOutputs(IEnumerable<TargetRelativePath> outputs, IFileSystemDirectory targetRoot, IFileSystemDirectory cacheDir)
{
using (var names = cacheDir.CreateTextFile(NamesFileName))
{
int idx = 0;
foreach (var outputPath in outputs)
{
try
{
// It is possible that the returned path is a special path and does not refer to an existing file
// In this case we only have to save the filename, without its contents
if (targetRoot.Exists(outputPath))
{
targetRoot.CopyFile(outputPath, cacheDir, idx.ToString(CultureInfo.InvariantCulture));
}
names.WriteLine("{0};{1}", outputPath.RelativeRoot, outputPath.RelativePath);
idx++;
}
catch (IOException ex)
{
log.WarnFormat("IOException while reading {0}: {1}", outputPath, ex.Message);
if (!outputPath.RelativePath.ToLowerInvariant().EndsWith(".vshost.exe"))
throw;
}
}
}
}