summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-12-15 19:25:50 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2009-12-15 19:25:50 -0800
commit8c0bcde31654fc4a0efff526b37b8fc386175abb (patch)
tree6201d5004323daf083bf1196bd4ffa103fb2891d
parenta59adef3b04544b519ce9d1d8110ba456fee159d (diff)
downloadDotNetOpenAuth-8c0bcde31654fc4a0efff526b37b8fc386175abb.zip
DotNetOpenAuth-8c0bcde31654fc4a0efff526b37b8fc386175abb.tar.gz
DotNetOpenAuth-8c0bcde31654fc4a0efff526b37b8fc386175abb.tar.bz2
Fixed incremental build when the project template transformation changes.
-rw-r--r--build.proj5
-rw-r--r--lib/DotNetOpenAuth.BuildTasks.dllbin56832 -> 56832 bytes
-rw-r--r--lib/DotNetOpenAuth.BuildTasks.pdbbin142848 -> 142848 bytes
-rw-r--r--src/DotNetOpenAuth.BuildTasks/CompareFiles.cs27
-rw-r--r--src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs14
5 files changed, 35 insertions, 11 deletions
diff --git a/build.proj b/build.proj
index 0f87c62..8cd0788 100644
--- a/build.proj
+++ b/build.proj
@@ -173,6 +173,9 @@
">
<BeforeTokens>%(RecursiveDir)</BeforeTokens>
<AfterTokens>$safeprojectname$</AfterTokens>
+ <!-- Projects can get changed after the transform+copy operation, so don't skip copying them. -->
+ <SkipUnchangedFiles Condition="'%(Extension)' != '.csproj'">true</SkipUnchangedFiles>
+ <SkipUnchangedFiles Condition="'%(Extension)' == '.csproj'">false</SkipUnchangedFiles>
</_ProjectTemplatesTransformSource>
<ProjectTemplatesSource Remove="@(_ProjectTemplatesTransformSource)" />
@@ -210,7 +213,7 @@
</Trim>
<MSBuild Projects="@(ProjectTemplates)" />
<Copy SourceFiles="@(ProjectTemplatesSource)" DestinationFiles="@(ProjectTemplatesLayout)" SkipUnchangedFiles="true" />
- <CopyWithTokenSubstitution SourceFiles="@(ProjectTemplatesTransformSource)" DestinationFiles="@(ProjectTemplatesTransformLayout)" SkipUnchangedFiles="true">
+ <CopyWithTokenSubstitution SourceFiles="@(ProjectTemplatesTransformSource)" DestinationFiles="@(ProjectTemplatesTransformLayout)">
<Output TaskParameter="CopiedFiles" ItemName="CopiedProjectTemplateFiles" />
</CopyWithTokenSubstitution>
<Purge Directories="$(ProjectTemplatesLayoutPath)"
diff --git a/lib/DotNetOpenAuth.BuildTasks.dll b/lib/DotNetOpenAuth.BuildTasks.dll
index 7ee2a0f..1958acc 100644
--- a/lib/DotNetOpenAuth.BuildTasks.dll
+++ b/lib/DotNetOpenAuth.BuildTasks.dll
Binary files differ
diff --git a/lib/DotNetOpenAuth.BuildTasks.pdb b/lib/DotNetOpenAuth.BuildTasks.pdb
index ec57153..b8fd372 100644
--- a/lib/DotNetOpenAuth.BuildTasks.pdb
+++ b/lib/DotNetOpenAuth.BuildTasks.pdb
Binary files differ
diff --git a/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs b/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs
index 691df20..51fcee4 100644
--- a/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs
+++ b/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs
@@ -81,5 +81,32 @@ namespace DotNetOpenAuth.BuildTasks {
return true;
}
+
+ /// <summary>
+ /// Tests whether a file is up to date with respect to another,
+ /// based on existence, last write time and file size.
+ /// </summary>
+ /// <param name="sourcePath">The source path.</param>
+ /// <param name="destPath">The dest path.</param>
+ /// <returns><c>true</c> if the files are the same; <c>false</c> if the files are different</returns>
+ internal static bool FastFileEqualityCheck(string sourcePath, string destPath) {
+ FileInfo sourceInfo = new FileInfo(sourcePath);
+ FileInfo destInfo = new FileInfo(destPath);
+
+ if (sourceInfo.Exists ^ destInfo.Exists) {
+ // Either the source file or the destination file is missing.
+ return false;
+ }
+
+ if (!sourceInfo.Exists) {
+ // Neither file exists.
+ return true;
+ }
+
+ // We'll say the files are the same if their modification date and length are the same.
+ return
+ sourceInfo.LastWriteTimeUtc == destInfo.LastWriteTimeUtc &&
+ sourceInfo.Length == destInfo.Length;
+ }
}
}
diff --git a/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs b/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs
index 3b81978..e17d8f2 100644
--- a/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs
+++ b/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs
@@ -18,15 +18,6 @@ namespace DotNetOpenAuth.BuildTasks {
/// </summary>
public class CopyWithTokenSubstitution : Task {
/// <summary>
- /// Gets or sets a value indicating whether the task should
- /// skip the copying of files that are unchanged between the source and destination.
- /// </summary>
- /// <value>
- /// <c>true</c> to skip copying files where the destination files are newer than the source files; otherwise, <c>false</c> to copy all files.
- /// </value>
- public bool SkipUnchangedFiles { get; set; }
-
- /// <summary>
/// Gets or sets the files to copy.
/// </summary>
/// <value>The files to copy.</value>
@@ -65,8 +56,11 @@ namespace DotNetOpenAuth.BuildTasks {
for (int i = 0; i < this.SourceFiles.Length; i++) {
string sourcePath = this.SourceFiles[i].ItemSpec;
string destPath = this.DestinationFiles[i].ItemSpec;
+ bool skipUnchangedFiles = bool.Parse(this.SourceFiles[i].GetMetadata("SkipUnchangedFiles"));
- if (this.SkipUnchangedFiles && File.GetLastWriteTimeUtc(sourcePath) < File.GetLastWriteTimeUtc(destPath)) {
+ // We deliberably consider newer destination files to be up-to-date rather than
+ // requiring equality because this task modifies the destination file while copying.
+ if (skipUnchangedFiles && File.GetLastWriteTimeUtc(sourcePath) < File.GetLastWriteTimeUtc(destPath)) {
Log.LogMessage(MessageImportance.Low, "Skipping \"{0}\" -> \"{1}\" because the destination is up to date.", sourcePath, destPath);
continue;
}