diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-15 15:30:38 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-15 15:30:38 -0800 |
commit | 588bc035f93607b4179df9f7f42175c08e6cf7b5 (patch) | |
tree | 965802693892616db01cf6997f060dda44518697 /src/DotNetOpenAuth.BuildTasks/AddProjectItems.cs | |
parent | 888abd61a54576ff244533693df77f174f03c2bb (diff) | |
parent | 2ff3e125a7db35ce459b89add580aedf7d2bd7d4 (diff) | |
download | DotNetOpenAuth-588bc035f93607b4179df9f7f42175c08e6cf7b5.zip DotNetOpenAuth-588bc035f93607b4179df9f7f42175c08e6cf7b5.tar.gz DotNetOpenAuth-588bc035f93607b4179df9f7f42175c08e6cf7b5.tar.bz2 |
Merged working branch that splits the RP project template into two projects: a web project and a class library.
Merge branch 'projecttemplateLib'
Diffstat (limited to 'src/DotNetOpenAuth.BuildTasks/AddProjectItems.cs')
-rw-r--r-- | src/DotNetOpenAuth.BuildTasks/AddProjectItems.cs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.BuildTasks/AddProjectItems.cs b/src/DotNetOpenAuth.BuildTasks/AddProjectItems.cs new file mode 100644 index 0000000..30fa284 --- /dev/null +++ b/src/DotNetOpenAuth.BuildTasks/AddProjectItems.cs @@ -0,0 +1,62 @@ +//----------------------------------------------------------------------- +// <copyright file="AddProjectItems.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.BuildEngine; + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + using System.Collections; + + public class AddProjectItems : Task { + /// <summary> + /// Gets or sets the projects to add items to. + /// </summary> + /// <value>The projects.</value> + [Required] + public ITaskItem[] Projects { get; set; } + + /// <summary> + /// Gets or sets the items to add to each project. + /// </summary> + /// <value>The items.</value> + /// <remarks> + /// Use the metadata "ItemType" on each item to specify the item type to use for the new + /// project item. If the metadata is absent, "None" is used as the item type. + /// </remarks> + [Required] + public ITaskItem[] Items { get; set; } + + /// <summary> + /// Executes this instance. + /// </summary> + public override bool Execute() { + foreach (var projectTaskItem in this.Projects) { + var project = new Project(); + project.Load(projectTaskItem.ItemSpec); + + foreach (var projectItem in this.Items) { + string itemType = projectItem.GetMetadata("ItemType"); + if (string.IsNullOrEmpty(itemType)) { + itemType = "None"; + } + BuildItem newItem = project.AddNewItem(itemType, projectItem.ItemSpec, false); + var customMetadata = projectItem.CloneCustomMetadata(); + foreach (DictionaryEntry entry in customMetadata) { + newItem.SetMetadata((string)entry.Key, (string)entry.Value); + } + } + + project.Save(projectTaskItem.ItemSpec); + } + + return !this.Log.HasLoggedErrors; + } + } +} |