[tasque/xbuild] [xbuild] Add task GetAbsPath



commit 4a468840a4ec42aa7ab2135a55b30f43d93ab4c9
Author: Antonius Riha <antoniusriha gmail com>
Date:   Thu Oct 18 20:22:23 2012 +0200

    [xbuild] Add task GetAbsPath

 build/GetAbsPath.cs    |   59 ++++++++++++++++++++++++++++++++++++++++++++++++
 build/X.Common.targets |    3 +-
 build/build.csproj     |    1 +
 3 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/build/GetAbsPath.cs b/build/GetAbsPath.cs
new file mode 100644
index 0000000..db280a4
--- /dev/null
+++ b/build/GetAbsPath.cs
@@ -0,0 +1,59 @@
+//
+// GetAbsPath.cs
+//
+// Author:
+//       Antonius Riha <antoniusriha gmail com>
+//
+// Copyright (c) 2012 Antonius Riha
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+
+namespace Tasque.Build
+{
+	public class GetAbsPath : Task
+	{
+		[Required]
+		public string Path { get; set; }
+		
+		[Output]
+		public string AbsolutePath { get; set; }
+		
+		public override bool Execute ()
+		{
+			try {
+				AbsolutePath = InternalGetAbsPath (Path);
+			} catch (Exception ex) {
+				Log.LogErrorFromException (ex, true);
+				return false;
+			}
+			return true;
+		}
+		
+		internal static string InternalGetAbsPath (string path)
+		{
+			if (path == null)
+				throw new ArgumentNullException ("path");
+			path = System.IO.Path.GetFullPath (path);
+			return NormalizePath.InternalNormalizePath (path);
+		}
+	}
+}
diff --git a/build/X.Common.targets b/build/X.Common.targets
index 198b5a5..79dc250 100644
--- a/build/X.Common.targets
+++ b/build/X.Common.targets
@@ -127,9 +127,10 @@
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <UsingTask TaskName="Tasque.Build.Substitute" AssemblyFile="build.dll" />
   <UsingTask TaskName="Tasque.Build.GetRelPath" AssemblyFile="build.dll" />
+  <UsingTask TaskName="Tasque.Build.GetAbsPath" AssemblyFile="build.dll" />
   <UsingTask TaskName="Tasque.Build.GetAbsSrcDir" AssemblyFile="build.dll" />
   <UsingTask TaskName="Tasque.Build.NormalizePath" AssemblyFile="build.dll" />
-	
+  
   <!-- Substitute -->
   <Target Name="Substitute" DependsOnTargets="BeforeSubstitute;CoreSubstitute;AfterSubstitute" />
   <Target Name="BeforeSubstitute" />
diff --git a/build/build.csproj b/build/build.csproj
index 870d010..b5e5522 100644
--- a/build/build.csproj
+++ b/build/build.csproj
@@ -36,6 +36,7 @@
     <Compile Include="GetRelPath.cs" />
     <Compile Include="GetAbsSrcDir.cs" />
     <Compile Include="NormalizePath.cs" />
+    <Compile Include="GetAbsPath.cs" />
   </ItemGroup>
   <ItemGroup>
     <Proj Include="..\src\Gtk.Tasque\Gtk.Tasque.csproj">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]