protected virtual bool NeedsCompiling()
{
if (!OutputFile.Exists) {
Log(Level.Verbose, ResourceUtils.GetString("String_OutputFileDoesNotExist"),
OutputFile.FullName);
return true;
}
string fileName = null;
// check if modules were updated
foreach (Module module in ModuleSet.Modules) {
fileName = FileSet.FindMoreRecentLastWriteTime(module.File, OutputFile.LastWriteTime);
if (fileName != null) {
Log(Level.Verbose, ResourceUtils.GetString("String_FileHasBeenUpdated"),
fileName);
return true;
}
}
// check if (embedded)resources were updated
fileName = FileSet.FindMoreRecentLastWriteTime(Resources.FileNames, OutputFile.LastWriteTime);
if (fileName != null) {
Log(Level.Verbose, ResourceUtils.GetString("String_FileHasBeenUpdated"),
fileName);
return true;
}
// check if evidence file was updated
if (EvidenceFile != null) {
fileName = FileSet.FindMoreRecentLastWriteTime(EvidenceFile.FullName, OutputFile.LastWriteTime);
if (fileName != null) {
Log(Level.Verbose, ResourceUtils.GetString("String_FileHasBeenUpdated"),
fileName);
return true;
}
}
// check if template file was updated
if (TemplateFile != null) {
fileName = FileSet.FindMoreRecentLastWriteTime(TemplateFile.FullName, OutputFile.LastWriteTime);
if (fileName != null) {
Log(Level.Verbose, ResourceUtils.GetString("String_FileHasBeenUpdated"),
fileName);
return true;
}
}
// check if key file was updated
if (KeyFile != null) {
fileName = FileSet.FindMoreRecentLastWriteTime(KeyFile.FullName, OutputFile.LastWriteTime);
if (fileName != null) {
Log(Level.Verbose, ResourceUtils.GetString("String_FileHasBeenUpdated"),
fileName);
return true;
}
}
// check if win32 icon file was updated
if (Win32Icon != null) {
fileName = FileSet.FindMoreRecentLastWriteTime(Win32Icon.FullName, OutputFile.LastWriteTime);
if (fileName != null) {
Log(Level.Verbose, ResourceUtils.GetString("String_FileHasBeenUpdated"),
fileName);
return true;
}
}
// check if win32 resource file was updated
if (Win32Res != null) {
fileName = FileSet.FindMoreRecentLastWriteTime(Win32Res.FullName, OutputFile.LastWriteTime);
if (fileName != null) {
Log(Level.Verbose, ResourceUtils.GetString("String_FileHasBeenUpdated"),
fileName);
return true;
}
}
// check if embedded resource files were updated
foreach (EmbeddedResource embeddedResource in EmbeddedResources) {
fileName = FileSet.FindMoreRecentLastWriteTime(embeddedResource.File,
OutputFile.LastWriteTime);
if (fileName != null) {
Log(Level.Verbose, ResourceUtils.GetString("String_FileHasBeenUpdated"),
fileName);
return true;
}
}
// check the arguments for /embed or /embedresource options
StringCollection embeddedResourceFiles = new StringCollection();
foreach (Argument argument in Arguments) {
if (argument.IfDefined && !argument.UnlessDefined) {
string argumentValue = argument.Value;
// check whether argument specifies resource file to embed
if (argumentValue != null && (argumentValue.StartsWith("/embed:") || argumentValue.StartsWith("/embedresource:"))) {
// determine path to resource file
string path = argumentValue.Substring(argumentValue.IndexOf(':') + 1);
int indexOfComma = path.IndexOf(',');
if (indexOfComma != -1) {
path = path.Substring(0, indexOfComma);
}
bool isQuoted = path.Length > 2 && path.StartsWith("\"") && path.EndsWith("\"");
if (isQuoted) {
path = path.Substring(1, path.Length - 2);
}
// resolve path to full path (relative to project base dir)
path = Project.GetFullPath(path);
// add path to collection of resource files
embeddedResourceFiles.Add(path);
}
}
}
// check if embedded resources passed as arguments were updated
fileName = FileSet.FindMoreRecentLastWriteTime(embeddedResourceFiles, OutputFile.LastWriteTime);
if (fileName != null) {
Log(Level.Verbose, ResourceUtils.GetString("String_FileHasBeenUpdated"),
fileName);
return true;
}
// if we made it here then we don't have to recompile
return false;
}