diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-10-24 15:56:48 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-10-24 15:56:48 -0700 |
commit | 9dbb9aab73812202648c4e68d60261dd84d6c8e2 (patch) | |
tree | 5de139019a7b2f870f84c57cac36c0e489bd1e41 /src/DotNetOpenAuth.BuildTasks/AddProjectItems.cs | |
parent | 4b27c330fbfb3a260aa3bd6a9b1232ee3b53deb0 (diff) | |
parent | e7ce41355c38b3125729a62920231f274b7a2100 (diff) | |
download | DotNetOpenAuth-origin/mono2.zip DotNetOpenAuth-origin/mono2.tar.gz DotNetOpenAuth-origin/mono2.tar.bz2 |
Merge branch 'v3.2' into mono2origin/mono2
Conflicts:
src/DotNetOpenAuth/Messaging/HttpRequestInfo.cs
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; + } + } +} |