[Microsoft.Build.Tasks] Add support for LogicalName in EmbeddedResources.
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Mon, 26 May 2014 16:17:36 +0000 (18:17 +0200)
committerRolf Bjarne Kvinge <rolf@xamarin.com>
Mon, 26 May 2014 16:22:34 +0000 (18:22 +0200)
mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/AL.cs
mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/ALTest.cs

index 1fc961b72dc1f56a4865b6a55bb1c583ef706087..f7ff0a2f9bea47d9cfca2d827deacc401fc1aea1 100644 (file)
@@ -57,9 +57,15 @@ namespace Microsoft.Build.Tasks {
                                else
                                        commandLine.AppendSwitch ("/delaysign-");
                        commandLine.AppendSwitchIfNotNull ("/description:", Description);
-                       if (EmbedResources != null)
-                               foreach (ITaskItem item in EmbedResources)
-                                       commandLine.AppendSwitchIfNotNull ("/embed:", item.ItemSpec);
+                       if (EmbedResources != null) {
+                               foreach (ITaskItem item in EmbedResources) {
+                                       string logical_name = item.GetMetadata ("LogicalName");
+                                       if (logical_name.Length > 0)
+                                               commandLine.AppendSwitchIfNotNull ("/embed:", string.Format ("{0},{1}", item.ItemSpec, logical_name));
+                                       else
+                                               commandLine.AppendSwitchIfNotNull ("/embed:", item.ItemSpec);
+                               }
+                       }
                        commandLine.AppendSwitchIfNotNull ("/evidence:", EvidenceFile);
                        commandLine.AppendSwitchIfNotNull ("/fileversion:", FileVersion);
                        commandLine.AppendSwitchIfNotNull ("/flags:", Flags);
index 7b92594d0b894ec9851372f3899ce0a710fc00e3..56f9ea36813e00b7d3b6b822eaa39372f026b613 100644 (file)
@@ -27,6 +27,7 @@
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using Microsoft.Build.BuildEngine;
 using Microsoft.Build.Framework;
 using Microsoft.Build.Tasks;
@@ -287,6 +288,20 @@ namespace MonoTests.Microsoft.Build.Tasks {
                        Assert.AreEqual ("/embed:a /embed:b", clbe.ToString (), "A1");
                }
 
+               [Test]
+               public void TestEmbedResourcesWithLogicalName ()
+               {
+                       ALExtended ale = new ALExtended ();
+                       CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
+                       var dict = new Dictionary<string, string> ();
+                       dict ["LogicalName"] = "value";
+
+                       ale.EmbedResources = new ITaskItem [2] { new TaskItem ("a", dict), new TaskItem ("b", dict) };
+                       ale.ARFC (clbe);
+
+                       Assert.AreEqual ("/embed:a,value /embed:b,value", clbe.ToString (), "A1");
+               }
+
                [Test]
                public void TestEvidenceFile ()
                {