#region License
/**
* Ingenious MVC : An MVC framework for .NET 2.0
* Copyright (C) 2006, JDP Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: - Kent Boogaart (kentcb@internode.on.net)
*/
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Xsl;
using Microsoft.Build.Framework;
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
namespace Ingenious.Mvc.Build{
/// <summary>
/// Implements a task to copy files to a special folder.
/// </summary>
/// <remarks>
/// This task is needed to copy files to a special folder - that is, a folder that has special meaning in a Windows environment.
/// </remarks>
public sealed class CopyToSpecialFolderTask : Task
{
private Copy _copy;
private string _specialFolder;
private string _subPath;
[Output]
public ITaskItem[] CopiedFiles
{
get
{
return _copy.CopiedFiles;
}
}
[Required]
public string SpecialFolder
{
get
{
return _specialFolder;
}
set
{
_specialFolder = value;
}
}
public string SubPath
{
get
{
return _subPath;
}
set
{
_subPath = value;
}
}
public bool SkipUnchangedFiles
{
get
{
return _copy.SkipUnchangedFiles;
}
set
{
_copy.SkipUnchangedFiles = value;
}
}
[Required]
public ITaskItem[] SourceFiles
{
get
{
return _copy.SourceFiles;
}
set
{
_copy.SourceFiles = value;
}
}
public CopyToSpecialFolderTask()
{
_copy = new Copy();
}
public override bool Execute()
{
//must assign the build engine, otherwise the copy task can't participate in the build process - it will throw
_copy.BuildEngine = BuildEngine;
Environment.SpecialFolder specialFolder = (Environment.SpecialFolder) Enum.Parse(typeof(Environment.SpecialFolder), _specialFolder);
string folder = Environment.GetFolderPath(specialFolder);
if (_subPath != null)
{
folder = Path.Combine(folder, _subPath);
}
//just assign the desination folder and then execute the copy task
_copy.DestinationFolder = new TaskItem(folder);
return _copy.Execute();
}
}
}
|