public void LoadChanges()
{
if (LastBuildVersionInfo == null)
{
throw new InvalidOperationException("Only incremental build could load changes.");
}
if (_parameters.Changes != null)
{
// use user-provided changelist
foreach (var pair in _parameters.Changes)
{
_changeDict[pair.Key] = pair.Value;
}
}
else
{
// get changelist from lastBuildInfo if user doesn't provide changelist
var lastFileAttributes = LastBuildVersionInfo.Attributes;
var fileAttributes = CurrentBuildVersionInfo.Attributes;
DateTime checkTime = LastBuildStartTime.Value;
foreach (var file in fileAttributes.Keys.Intersect(lastFileAttributes.Keys))
{
var last = lastFileAttributes[file];
var current = fileAttributes[file];
if (current.LastModifiedTime > checkTime && current.MD5 != last.MD5)
{
_changeDict[file] = ChangeKindWithDependency.Updated;
}
else
{
_changeDict[file] = ChangeKindWithDependency.None;
}
}
foreach (var file in lastFileAttributes.Keys.Except(fileAttributes.Keys))
{
_changeDict[file] = ChangeKindWithDependency.Deleted;
}
foreach (var file in fileAttributes.Keys.Except(lastFileAttributes.Keys))
{
_changeDict[file] = ChangeKindWithDependency.Created;
}
}
}