public bool ShouldCopyFile(string fileName, string directory)
{
if (!fileSystem.FileExists(fileName)) return true;
if (_copyMode == AssemblyCopyMode.Always) return true;
if (_copyMode == AssemblyCopyMode.SemVerCompatible && Path.GetExtension(fileName) == ".dll")
{
var sourceVersion = _assembly.GetName().Version;
var currentVersion = AssemblyVersionOf(fileName);
if (!IsSemVerCompatible(sourceVersion, currentVersion))
{
var template = "The versions of {0} in the source {1} ({2}) and destination directory {3} ({4}) are incompatible";
throw new Exception(template.ToFormat(_assembly.GetName().Name, _assembly.Location, sourceVersion.ToString(), directory, currentVersion.ToString()));
}
}
return false;
}