summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-01-15 08:06:52 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2010-01-15 08:06:52 -0800
commitc1ea54f5fb761f388593a484510fc29118a844b5 (patch)
tree6c4399698c525f7860e3750acba7a2a4aa977bc8 /src
parent098e34ea4f12a3c22d3647e611a13d74e8ce754e (diff)
downloadDotNetOpenAuth-c1ea54f5fb761f388593a484510fc29118a844b5.zip
DotNetOpenAuth-c1ea54f5fb761f388593a484510fc29118a844b5.tar.gz
DotNetOpenAuth-c1ea54f5fb761f388593a484510fc29118a844b5.tar.bz2
Both .vsi and .vsix files are built now!
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DiscoverProjectTemplates.cs1
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj2
-rw-r--r--src/DotNetOpenAuth.BuildTasks/HardLinkCopy.cs61
-rw-r--r--src/DotNetOpenAuth.BuildTasks/NativeMethods.cs18
4 files changed, 82 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.BuildTasks/DiscoverProjectTemplates.cs b/src/DotNetOpenAuth.BuildTasks/DiscoverProjectTemplates.cs
index 0162c16..f49c9b1 100644
--- a/src/DotNetOpenAuth.BuildTasks/DiscoverProjectTemplates.cs
+++ b/src/DotNetOpenAuth.BuildTasks/DiscoverProjectTemplates.cs
@@ -15,6 +15,7 @@ namespace DotNetOpenAuth.BuildTasks {
using Microsoft.Build.Utilities;
public class DiscoverProjectTemplates : Task {
+ [Required]
public ITaskItem[] TopLevelTemplates { get; set; }
[Output]
diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
index 7dcc5d0..daf6327 100644
--- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
+++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
@@ -109,10 +109,12 @@
<Compile Include="FilterItems.cs" />
<Compile Include="FixupReferenceHintPaths.cs" />
<Compile Include="FixupShippingToolSamples.cs" />
+ <Compile Include="HardLinkCopy.cs" />
<Compile Include="MergeProjectWithVSTemplate.cs" />
<Compile Include="GetBuildVersion.cs" />
<Compile Include="CheckAdminRights.cs" />
<Compile Include="JsPack.cs" />
+ <Compile Include="NativeMethods.cs" />
<Compile Include="ParseMaster.cs" />
<Compile Include="Publicize.cs" />
<Compile Include="Purge.cs" />
diff --git a/src/DotNetOpenAuth.BuildTasks/HardLinkCopy.cs b/src/DotNetOpenAuth.BuildTasks/HardLinkCopy.cs
new file mode 100644
index 0000000..af2d1d0
--- /dev/null
+++ b/src/DotNetOpenAuth.BuildTasks/HardLinkCopy.cs
@@ -0,0 +1,61 @@
+//-----------------------------------------------------------------------
+// <copyright file="HardLinkCopy.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.BuildTasks {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using Microsoft.Build.Framework;
+ using Microsoft.Build.Utilities;
+ using System.IO;
+
+ public class HardLinkCopy : Task {
+ [Required]
+ public ITaskItem[] SourceFiles { get; set; }
+
+ [Required]
+ public ITaskItem[] DestinationFiles { get; set; }
+
+ /// <summary>
+ /// Executes this instance.
+ /// </summary>
+ public override bool Execute() {
+ if (this.SourceFiles.Length != this.DestinationFiles.Length) {
+ this.Log.LogError("SourceFiles has {0} elements and DestinationFiles has {1} elements.", this.SourceFiles.Length, this.DestinationFiles.Length);
+ return false;
+ }
+
+ for (int i = 0; i < this.SourceFiles.Length; i++) {
+ bool hardLink;
+ bool.TryParse(this.DestinationFiles[i].GetMetadata("HardLink"), out hardLink);
+ string sourceFile = this.SourceFiles[i].ItemSpec;
+ string destinationFile = this.DestinationFiles[i].ItemSpec;
+ this.Log.LogMessage(
+ MessageImportance.Low,
+ "Copying {0} -> {1}{2}.",
+ sourceFile,
+ destinationFile,
+ hardLink ? " as hard link" : string.Empty);
+
+ if (!Directory.Exists(Path.GetDirectoryName(destinationFile))) {
+ Directory.CreateDirectory(Path.GetDirectoryName(destinationFile));
+ }
+
+ if (hardLink) {
+ if (File.Exists(destinationFile)) {
+ File.Delete(destinationFile);
+ }
+ NativeMethods.CreateHardLink(sourceFile, destinationFile);
+ } else {
+ File.Copy(sourceFile, destinationFile, true);
+ }
+ }
+
+ return !this.Log.HasLoggedErrors;
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.BuildTasks/NativeMethods.cs b/src/DotNetOpenAuth.BuildTasks/NativeMethods.cs
new file mode 100644
index 0000000..26de3a4
--- /dev/null
+++ b/src/DotNetOpenAuth.BuildTasks/NativeMethods.cs
@@ -0,0 +1,18 @@
+namespace DotNetOpenAuth.BuildTasks {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Runtime.InteropServices;
+
+ internal static class NativeMethods {
+ [DllImport("kernel32", SetLastError = true)]
+ private static extern bool CreateHardLink(string newFileName, string existingFileName, IntPtr securityAttributes);
+
+ internal static void CreateHardLink(string existingFileName, string newFileName) {
+ if (!CreateHardLink(newFileName, existingFileName, IntPtr.Zero)) {
+ Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
+ }
+ }
+ }
+}