[tasque/transition: 132/213] Add a build task that checks if prefix is an absolute path



commit d36412a543970f704cd62b3200cec46a38c2b124
Author: Antonius Riha <antoniusriha gmail com>
Date:   Fri Aug 17 22:04:14 2012 +0200

    Add a build task that checks if prefix is an absolute path

 build/CheckPrefix.cs |   51 ++++++++++++++++++++++++++++++++++++++++++++++++++
 build/build.csproj   |    5 ++++
 2 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/build/CheckPrefix.cs b/build/CheckPrefix.cs
new file mode 100644
index 0000000..39509fe
--- /dev/null
+++ b/build/CheckPrefix.cs
@@ -0,0 +1,51 @@
+// 
+// CheckPrefix.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 System.IO;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+
+namespace Tasque.Build
+{
+	public class CheckPrefix : Task
+	{
+		[Required]
+		public ITaskItem Prefix { get; set; }
+		
+		public override bool Execute ()
+		{
+			try {
+				if (!Path.IsPathRooted (Prefix.ItemSpec))
+					throw new Exception ("Prefix must be an absolute path.");
+				
+			} catch (Exception ex) {
+				Log.LogErrorFromException (ex, true);
+				return false;
+			}
+			return true;
+		}
+	}
+}
diff --git a/build/build.csproj b/build/build.csproj
index 80d228b..5801f13 100644
--- a/build/build.csproj
+++ b/build/build.csproj
@@ -31,6 +31,7 @@
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <UsingTask AssemblyFile="bin\Tasque.Build.dll" TaskName="Tasque.Build.SetDataAtBuildTime" />
   <UsingTask AssemblyFile="bin\Tasque.Build.dll" TaskName="Tasque.Build.LoadGitSubmodules" />
+  <UsingTask AssemblyFile="bin\Tasque.Build.dll" TaskName="Tasque.Build.CheckPrefix" />
   <ItemGroup>
     <None Include="build.csproj" />
     <None Include="..\tasque.sln">
@@ -96,6 +97,7 @@
   <ItemGroup>
     <Compile Include="SetDataAtBuildTime.cs" />
     <Compile Include="LoadGitSubmodules.cs" />
+    <Compile Include="CheckPrefix.cs" />
   </ItemGroup>
   <ItemGroup>
     <GlobalDefines Include="GlobalDefines.cs" />
@@ -115,6 +117,9 @@
     <Reference Include="System" />
   </ItemGroup>
   <Target Name="AfterBuild">
+    <Message Text="Checking prefix..." />
+    <CheckPrefix Prefix="$(Prefix)" />
+    <Message Text="Finished checking prefix." />
     <Message Text="Setting up global definitions..." />
     <SetDataAtBuildTime AuthorsFile="@(Authors)" CopyingFile="@(License)" Prefix="$(Prefix)" GlobalDefinesFile="@(GlobalDefines)" GlobalDefinesFileIn="@(GlobalDefinesIn)" Version="$(ReleaseVersion)" Website="$(Website)" />
     <Message Text="Finished setting up global definitions." />



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