Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
jcde committed May 14, 2014
1 parent b4b7366 commit 05ca6bd
Show file tree
Hide file tree
Showing 14 changed files with 441 additions and 0 deletions.
57 changes: 57 additions & 0 deletions NAnt.Utils/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Reflection;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly : AssemblyTitle("")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("")]
[assembly : AssemblyCopyright("")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]

//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly : AssemblyVersion("1.0")]

//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly : AssemblyDelaySign(true)]
[assembly : AssemblyKeyFile(@"../../../../Configuration/Keys/numsite.snk")]
[assembly : AssemblyKeyName("")]
118 changes: 118 additions & 0 deletions NAnt.Utils/NAnt.Utils.Tasks.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8FFF06DC-F74C-4354-9846-8687E7B41E38}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>NAnt.Utils.Tasks</AssemblyName>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>NAnt.Utils.Tasks</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>0.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG;TRACE;UNIT_TESTS</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<Name>log4net</Name>
<HintPath>..\..\Framework\log4net.DLL</HintPath>
</Reference>
<Reference Include="NAnt.Core">
<Name>NAnt.Core</Name>
<HintPath>..\..\Framework\NAnt.Core.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<Name>nunit.framework</Name>
<HintPath>..\..\Framework\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PathAbsolute2Relative.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlListTask.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
19 changes: 19 additions & 0 deletions NAnt.Utils/NAnt.Utils.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAnt.Utils.Tasks", "NAnt.Utils.Tasks.csproj", "{8FFF06DC-F74C-4354-9846-8687E7B41E38}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8FFF06DC-F74C-4354-9846-8687E7B41E38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FFF06DC-F74C-4354-9846-8687E7B41E38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FFF06DC-F74C-4354-9846-8687E7B41E38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FFF06DC-F74C-4354-9846-8687E7B41E38}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions NAnt.Utils/NAnt.Utils.sln.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<project default="build">

<include buildfile="${environment::get-variable('currentDeploy')}" />

</project>
163 changes: 163 additions & 0 deletions NAnt.Utils/PathAbsolute2Relative.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
using System;
using System.IO;
using System.Text;

using NAnt.Core;
using NAnt.Core.Attributes;

using NUnit.Framework;

namespace NAnt.Utils.Tasks
{
[TaskName("pathabsolute2relative")]
public class PathAbsolute2Relative : Task
{
private string _relativePathProp;
private string _absPath;
private string _baseDir;
internal string Result;

[TaskAttribute("absPath", Required = true)]
[StringValidator(AllowEmpty = false)]
public string AbsPath
{
get { return _absPath.Replace("/", @"\").Replace(@"file:\", ""); }
set { _absPath = value; }
}

[TaskAttribute("relativePathProp", Required = true)]
[StringValidator(AllowEmpty = false)]
public string RelativePathProp
{
get { return _relativePathProp; }
set { _relativePathProp = value; }
}

[TaskAttribute("baseDir", Required = true)]
[StringValidator(AllowEmpty = false)]
public string BaseDir
{
get { return _baseDir.Replace("/", @"\").Replace(@"file:\", "").TrimEnd('\\'); }
set { _baseDir = value; }
}

protected override void ExecuteTask()
{
string absDir = Path.GetDirectoryName(AbsPath).TrimEnd('\\');

int i = 0;
string[] baseDirArray = BaseDir.Split('\\');
string[] absDirArray = absDir.Split('\\');
foreach (string s in absDirArray)
{
if (i >= baseDirArray.Length || baseDirArray[i] != s)
{
break;
}
i++;
}

StringBuilder builder = new StringBuilder();
for (int j = i; j < baseDirArray.Length; j++)
{
builder.Append(@"..\");
}
for (int j = i; j < absDirArray.Length; j++)
{
builder.Append(absDirArray[j]);
builder.Append(@"\");
}

builder.Append(Path.GetFileName(AbsPath));
Result = builder.ToString();
if (Project != null)
{
if (Project.Properties.Contains(RelativePathProp))
{
Project.Properties[RelativePathProp] = Result;
}
else
{
Project.Properties.Add(RelativePathProp, Result);
}
}
}

#if UNIT_TESTS
[TestFixture]
public class Tests
{
[Test]
public void TestAbsMoreBase1()
{
PathAbsolute2Relative task = new PathAbsolute2Relative();
task.AbsPath = @"d:\1\ports.list";
task.BaseDir = @"d:\";
task.ExecuteTask();
Assert.AreEqual(@"1\ports.list", task.Result);
}

[Test]
public void TestAbsMoreBase2()
{
PathAbsolute2Relative task = new PathAbsolute2Relative();
task.AbsPath = @"d:\1\2\ports.list";
task.BaseDir = @"d:\1";
task.ExecuteTask();
Assert.AreEqual(@"2\ports.list", task.Result);
}

[Test]
public void TestAbsMoreBase3()
{
PathAbsolute2Relative task = new PathAbsolute2Relative();
task.AbsPath = @"d:\1\2\ports.list";
task.BaseDir = @"c:\1";
task.ExecuteTask();
Assert.AreEqual(@"..\..\d:\1\2\ports.list", task.Result);
}

[Test]
public void TestAbsSameBase1()
{
PathAbsolute2Relative task = new PathAbsolute2Relative();
task.AbsPath = @"d:\1\ports.list";
task.BaseDir = @"d:\1";
task.ExecuteTask();
Assert.AreEqual(@"ports.list", task.Result);
}

[Test]
public void TestAbsSameBase2()
{
PathAbsolute2Relative task = new PathAbsolute2Relative();
task.AbsPath = @"d:\ports.list";
task.BaseDir = @"d:\";
task.ExecuteTask();
Assert.AreEqual(@"ports.list", task.Result);
}

[Test]
public void TestAbsLessBase1()
{
PathAbsolute2Relative task = new PathAbsolute2Relative();
task.AbsPath = @"d:\1\ports.list";
task.BaseDir = @"d:\1\2\3";
task.ExecuteTask();
Assert.AreEqual(@"..\..\ports.list", task.Result);
}

[Test]
public void Example1()
{
PathAbsolute2Relative task = new PathAbsolute2Relative();
task.AbsPath = @"D:\sites\NumSite\Sources\Core\bin\Debug\AppConfiguration.dll";
task.BaseDir = @"D:\sites\NumSite\Sources\Projects\Portal\Code\Portal.Business";
task.ExecuteTask();
Assert.AreEqual(@"..\..\..\..\Core\bin\Debug\AppConfiguration.dll", task.Result);
}

}
#endif
}
}
Loading

0 comments on commit 05ca6bd

Please sign in to comment.