public void AddDependencies(ProjectInfo[] depends)
		{
			foreach (ProjectInfo proj in depends)
			{
				BuildItem bi = new BuildItem("Reference", proj.AssemblyName);
				bi.SetMetadata("SpecificVersion", false.ToString());
				bi.SetMetadata("HintPath", proj.AbsoluteOutputPath);
				_psedoDepends.Add(new ProjectRef(bi, GetProjectPath));
			}
		}
        public void BasicProxying()
        {          
            BuildItemGroup ig = new BuildItemGroup();
            BuildItem i1 = new BuildItem("name1", "value1");
            i1.SetMetadata("myMetaName", "myMetaValue");
            BuildItem i2 = new BuildItem("name2", "value2");
            ig.AddItem(i1);
            ig.AddItem(i2);

            BuildItemGroupProxy proxy = new BuildItemGroupProxy(ig);

            // Gather everything into our own table
            Hashtable list = new Hashtable(StringComparer.OrdinalIgnoreCase);
            foreach (DictionaryEntry item in proxy)
            {
                list.Add(item.Key, item.Value);
            }

            // Check we got all the items
            Assertion.AssertEquals(2, list.Count);
            Assertion.AssertEquals("value1", ((TaskItem)list["name1"]).ItemSpec);
            Assertion.AssertEquals("value2", ((TaskItem)list["name2"]).ItemSpec);

            // Check they have all their metadata
            int builtInMetadata = FileUtilities.ItemSpecModifiers.All.Length;
            Assertion.AssertEquals(1 + builtInMetadata, ((TaskItem)list["name1"]).MetadataCount);
            Assertion.AssertEquals(0 + builtInMetadata, ((TaskItem)list["name2"]).MetadataCount);
            Assertion.AssertEquals("myMetaValue", ((TaskItem)list["name1"]).GetMetadata("myMetaName"));
        }
Example #3
0
        void SetMetadata(string metadataName,
                         string metadataValue,
                         bool treatMetadataValueAsLiteral,
                         bool fromDynamicItem)
        {
            if (metadataName == null)
            {
                throw new ArgumentNullException("metadataName");
            }

            if (metadataValue == null)
            {
                throw new ArgumentNullException("metadataValue");
            }

            if (ReservedNameUtils.IsReservedMetadataName(metadataName))
            {
                throw new ArgumentException(String.Format("\"{0}\" is a reserved item meta-data, and cannot be modified or deleted.",
                                                          metadataName));
            }

            if (treatMetadataValueAsLiteral && !HasParentItem)
            {
                metadataValue = MSBuildUtils.Escape(metadataValue);
            }

            if (FromXml)
            {
                XmlElement element = itemElement [metadataName];
                if (element == null)
                {
                    element           = itemElement.OwnerDocument.CreateElement(metadataName, Project.XmlNamespace);
                    element.InnerText = metadataValue;
                    itemElement.AppendChild(element);
                }
                else
                {
                    element.InnerText = metadataValue;
                }
            }
            else if (HasParentItem)
            {
                if (parent_item.child_items.Count > 1)
                {
                    SplitParentItem();
                }
                parent_item.SetMetadata(metadataName, metadataValue, treatMetadataValueAsLiteral, fromDynamicItem);
            }

            // We don't want to reevalute the project for dynamic items
            if (!fromDynamicItem && !IsDynamic && (FromXml || HasParentItem))
            {
                parent_item_group.ParentProject.MarkProjectAsDirty();
                parent_item_group.ParentProject.NeedToReevaluate();
            }

            DeleteMetadata(metadataName);
            AddMetadata(metadataName, metadataValue);
        }
Example #4
0
 internal static void AddItemToGroup(MSBuild.BuildItemGroup group, ProjectItem item)
 {
     if (group == null)
     {
         throw new ArgumentNullException("group");
     }
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     if (item.IsAddedToProject)
     {
         throw new ArgumentException("item is already added to project", "item");
     }
     MSBuild.BuildItem newItem = group.AddNewItem(item.ItemType.ToString(), item.Include, item.TreatIncludeAsLiteral);
     foreach (string name in item.MetadataNames)
     {
         newItem.SetMetadata(name, item.GetMetadata(name));
     }
     item.BuildItem = newItem;
     Debug.Assert(item.IsAddedToProject);
 }
Example #5
0
        /// <summary>
        /// Set an attribute on the project element
        /// </summary>
        /// <param name="attributeName">Name of the attribute to set</param>
        /// <param name="attributeValue">Value to give to the attribute</param>
        public void SetMetadata(string attributeName, string attributeValue)
        {
            Debug.Assert(String.Compare(attributeName, ProjectFileConstants.Include, StringComparison.OrdinalIgnoreCase) != 0, "Use rename as this won't work");

            if (this.IsVirtual)
            {
                // For virtual node, use our virtual property collection
                if (virtualProperties.ContainsKey(attributeName))
                {
                    virtualProperties.Remove(attributeName);
                }
                virtualProperties.Add(attributeName, attributeValue);
                return;
            }

            // Build Action is the type, not a property, so intercept
            if (String.Compare(attributeName, ProjectFileConstants.BuildAction, StringComparison.OrdinalIgnoreCase) == 0)
            {
                item.Name = attributeValue;
                return;
            }

            // Check out the project file.
            if (!this.itemProject.QueryEditProjectFile(false))
            {
                throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
            }

            if (attributeValue == null)
            {
                item.RemoveMetadata(attributeName);
            }
            else
            {
                item.SetMetadata(attributeName, attributeValue);
            }
            itemProject.SetProjectFileDirty(true);
        }
        public void CantModifyThroughEnumerator()
        {
            BuildItemGroup ig = new BuildItemGroup();
            BuildItem i1 = new BuildItem("name1", "value1");
            i1.SetMetadata("myMetaName", "myMetaValue");
            ig.AddItem(i1);

            BuildItemGroupProxy proxy = new BuildItemGroupProxy(ig);

            Hashtable list = new Hashtable(StringComparer.OrdinalIgnoreCase);
            foreach (DictionaryEntry item in proxy)
            {
                list.Add(item.Key, item.Value);
            }

            // Change the item
            Assertion.AssertEquals("value1", ((TaskItem)list["name1"]).ItemSpec);
            ((TaskItem)list["name1"]).ItemSpec = "newItemSpec";
            ((TaskItem)list["name1"]).SetMetadata("newMetadata", "newMetadataValue");

            // We did change our copy
            Assertion.AssertEquals("newItemSpec", ((TaskItem)list["name1"]).ItemSpec);
            Assertion.AssertEquals("newMetadataValue", ((TaskItem)list["name1"]).GetMetadata("newMetadata"));
            Assertion.AssertEquals("myMetaValue", ((TaskItem)list["name1"]).GetMetadata("myMetaName"));

            // But get the item again
            list = new Hashtable(StringComparer.OrdinalIgnoreCase);
            foreach (DictionaryEntry item in proxy)
            {
                list.Add(item.Key, item.Value);
            }

            // Item value and metadata hasn't changed
            Assertion.AssertEquals("value1", ((TaskItem)list["name1"]).ItemSpec);
            Assertion.AssertEquals("", ((TaskItem)list["name1"]).GetMetadata("newMetadata"));
            Assertion.AssertEquals("myMetaValue", ((TaskItem)list["name1"]).GetMetadata("myMetaName"));
        }
Example #7
0
		public void TestCopyCustomMetadataTo2 ()
		{
			BuildItem item = new BuildItem ("name", "include");
			item.SetMetadata ("name", "value");
			
			item.CopyCustomMetadataTo (null);
		}
Example #8
0
		public void TestCopyCustomMetadataTo1 ()
		{
			BuildItem source, destination;
			string itemName1 = "a";
			string itemName2 = "b";
			string itemInclude = "a;b;c";
			string metadataName = "name";
			string metadataValue = "value";

			source = new BuildItem (itemName1, itemInclude);
			destination = new BuildItem (itemName2, itemInclude);

			source.SetMetadata (metadataName, metadataValue);

			source.CopyCustomMetadataTo (destination);

			Assert.AreEqual (metadataValue, destination.GetMetadata (metadataName), "A1");
			Assert.AreEqual (metadataValue, destination.GetEvaluatedMetadata (metadataName), "A2");
		}
Example #9
0
        public void RemoveItemFromProjectPreviouslyModifiedAndGottenThroughGetItem()
        {
            // Create some project state with an item with m=m1 and n=n1 
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            BuildItem item1 = new BuildItem("i1", "a2");
            item1.SetMetadata("m", "m1");
            BuildItemGroup group0 = new BuildItemGroup();
            group0.AddExistingItem(item1);
            table1["i1"] = group0;

            Lookup lookup = LookupHelpers.CreateLookup(table1);

            lookup.EnterScope();

            // Make a modification to the item to be m=m2
            Dictionary<string, string> newMetadata = new Dictionary<string, string>();
            newMetadata.Add("m", "m2");
            BuildItemGroup group = new BuildItemGroup();
            group.AddItem(item1);
            lookup.ModifyItems(item1.Name, group, newMetadata);

            // Get the item (under the covers, it cloned it in order to apply the modification)
            BuildItemGroup group2 = lookup.GetItems(item1.Name);
            Assertion.AssertEquals(1, group2.Count);
            BuildItem item1b = group2[0];

            // Remove the item
            lookup.RemoveItem(item1b);

            // There's now no items at all
            BuildItemGroup group3 = lookup.GetItems(item1.Name);
            Assertion.AssertEquals(0, group3.Count);

            // Leave scope
            lookup.LeaveScope();

            // And now none left in the project either
            Assertion.AssertEquals(0, ((BuildItemGroup)table1["i1"]).Count);
        }
Example #10
0
        /// <summary>
        /// Helper for trying invalid item names
        /// </summary>
        /// <param name="name"></param>
        private void TryInvalidItemName(string name)
        {
            XmlDocument doc = new XmlDocument();
            bool caughtException = false;

            // Test the BuildItem ctor
            try
            {
                BuildItem item = new BuildItem(doc, name, "someItemSpec", new ItemDefinitionLibrary(new Project()));
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                caughtException = true;
            }
            Assertion.Assert(name, caughtException);

            // Test the Name setter codepath
            caughtException = false;
            try
            {
                BuildItem item = new BuildItem(doc, "someName", "someItemSpec", new ItemDefinitionLibrary(new Project()));
                item.Name = name;
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                caughtException = true;
            }
            Assertion.Assert(name, caughtException);

            // Test the metadata setter codepath
            caughtException = false;
            try
            {
                BuildItem item = new BuildItem(doc, "someName", "someItemSpec", new ItemDefinitionLibrary(new Project()));
                item.SetMetadata(name, "someValue");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                caughtException = true;
            }
            Assertion.Assert(name, caughtException);
        }
Example #11
0
		public void TestSetMetadata4 ()
		{
			item = new BuildItem ("name", "include");
			item.SetMetadata ("Filename", "something");
		}
Example #12
0
		public void TestSetMetadata2 ()
		{
			item = new BuildItem ("name", "include");
			item.SetMetadata ("name", null);
		}
Example #13
0
		public void TestHasMetadata1 ()
		{
			string itemName = "a";
			string itemInclude = "a";
			string metadataName = "name";

			item = new BuildItem (itemName, itemInclude);

			Assert.AreEqual (false, item.HasMetadata (metadataName), "A1");

			item.SetMetadata (metadataName, "value");

			Assert.AreEqual (true, item.HasMetadata (metadataName), "A2");
			Assert.IsTrue (item.HasMetadata ("FullPath"), "A3");
			Assert.IsTrue (item.HasMetadata ("RootDir"), "A4");
			Assert.IsTrue (item.HasMetadata ("Filename"), "A5");
			Assert.IsTrue (item.HasMetadata ("Extension"), "A6");
			Assert.IsTrue (item.HasMetadata ("RelativeDir"), "A7");
			Assert.IsTrue (item.HasMetadata ("Directory"), "A8");
			Assert.IsTrue (item.HasMetadata ("RecursiveDir"), "A9");
			Assert.IsTrue (item.HasMetadata ("Identity"), "A10");
			Assert.IsTrue (item.HasMetadata ("ModifiedTime"), "A11");
			Assert.IsTrue (item.HasMetadata ("CreatedTime"), "A12");
			Assert.IsTrue (item.HasMetadata ("AccessedTime"), "A13");
		}
Example #14
0
        internal static BuildItem GetXmlBackedItemWithDefinitionLibrary()
        {
            string content = @"<i  xmlns='http://schemas.microsoft.com/developer/msbuild/2003' Include='i1'/>";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(content);

            XmlElement groupElement = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement itemElement = XmlTestUtilities.AddChildElement(groupElement, "i");
            XmlElement metaElement = XmlTestUtilities.AddChildElementWithInnerText(itemElement, "m", "m1");
            XmlElement metaElement2 = XmlTestUtilities.AddChildElementWithInnerText(itemElement, "o", "o1");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());
            library.Add(groupElement);
            library.Evaluate(null);

            BuildItem item = new BuildItem((XmlElement)doc.FirstChild, false, library);
            item.SetMetadata("n", "n1");
            return item;
        }
Example #15
0
        public void CreateClonedParentedItem()
        {
            BuildItem parent = GetXmlBackedItemWithDefinitionLibrary();
            BuildItem child = new BuildItem("i", "i2");
            child.SetMetadata("n", "n2");

            BuildItem clone = BuildItem.CreateClonedParentedItem(child, parent);

            Assertion.AssertEquals("i", clone.Name);
            Assertion.AssertEquals("i2", clone.EvaluatedItemSpec);
            Assertion.AssertEquals("i2", clone.FinalItemSpec);
            Assertion.AssertEquals("i2", clone.FinalItemSpecEscaped);

            // Make sure the itemdefinitionlibrary is cloned, too
            Assertion.AssertEquals("m1", clone.GetEvaluatedMetadata("m"));
            Assertion.AssertEquals("n1", clone.GetEvaluatedMetadata("n"));
        }
Example #16
0
 protected override void OnAddResource(BuildItem item)
 {
     item.SetMetadata("Generator", "ResXFileCodeGenerator");
 }
Example #17
0
        public override BuildItem AddContentBuildItem(string absoluteFile)
        {
            string relativeFileName = FileManager.MakeRelative(absoluteFile, this.Directory);
            BuildItem buildItem = null;

            string extension = FileManager.GetExtension(absoluteFile);

            buildItem = new BuildItem(FileManager.RemovePath(FileManager.RemoveExtension(absoluteFile)) + extension, relativeFileName.Replace("/", "\\"));
         

            string name = FileManager.RemovePath(FileManager.RemoveExtension(relativeFileName));

            buildItem.SetMetadata("Name", name);
                mBuildItemDictionaries.Add(buildItem.Include.ToLower(), buildItem);


            UpdateContentFile(absoluteFile.Replace("/", "\\"));
            return buildItem;
        }
Example #18
0
        private static Lookup GenerateLookup(BuildPropertyGroup properties)
        {
            BuildItemGroup items = new BuildItemGroup();
            BuildItem item1 = new BuildItem("i0", "a1");
            BuildItem item2 = new BuildItem("i0", "a2");
            BuildItem item3 = new BuildItem("i0", "a3");
            BuildItem item4 = new BuildItem("i0", "a4");
            item1.SetMetadata("m", "m1");
            item1.SetMetadata("n", "n1");
            item2.SetMetadata("m", "m2");
            item2.SetMetadata("n", "n2");
            item3.SetMetadata("m", "m2");
            item3.SetMetadata("n", "n2");
            item4.SetMetadata("m", "m3");
            item4.SetMetadata("n", "n3");
            items.AddItem(item1);
            items.AddItem(item2);
            items.AddItem(item3);
            items.AddItem(item4);
            Hashtable itemsByName = new Hashtable(StringComparer.OrdinalIgnoreCase);
            itemsByName.Add("i0", items);

            Lookup lookup = LookupHelpers.CreateLookup(properties, itemsByName);

            return lookup;
        }
Example #19
0
        private static BuildResult CreateBuildResult()
        {
            BuildItem buildItem1 = new BuildItem(null, "Item1");
            BuildItem buildItem2 = new BuildItem("BuildItem2", "Item2");
            BuildItem buildItem3 = BuildItem_Tests.GetXmlBackedItemWithDefinitionLibrary(); // default metadata m=m1 and o=o1
            buildItem1.Include = "TestInclude1";
            buildItem2.Include = "TestInclude2";
            buildItem1.SetMetadata("m", "m1");
            buildItem1.SetMetadata("n", "n1");
            buildItem3.SetMetadata("n", "n1");
            buildItem3.SetMetadata("o", "o2");
            BuildItem[] taskItems = new BuildItem[3];
            taskItems[0] = buildItem1;
            taskItems[1] = buildItem2;
            taskItems[2] = buildItem3;

            Dictionary<object, object> dictionary = new Dictionary<object, object>();
            dictionary.Add("TaskItems", taskItems);

            BuildResult resultWithOutputs = new BuildResult(dictionary, new Hashtable(StringComparer.OrdinalIgnoreCase), true, 0, 1, 2, true, "Foo", "Fighter", 1, 2, 3);
            resultWithOutputs.ResultByTarget.Add("ONE", Target.BuildState.CompletedSuccessfully);
            resultWithOutputs.HandleId = 0;
            resultWithOutputs.RequestId = 1;
            return resultWithOutputs;
        }
Example #20
0
		public void TestGetMetadata1 ()
		{
			string itemName = "a";
			string itemInclude = "a;b;c";
			string metadataName = "name";
			string metadataValue = "a;b;c";

			item = new BuildItem (itemName, itemInclude);

			Assert.AreEqual (String.Empty, item.GetMetadata (metadataName), "A1");

			item.SetMetadata (metadataName, metadataValue);

			Assert.AreEqual (metadataValue, item.GetMetadata (metadataName), "A2");
			Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (Utilities.Escape (itemInclude)), "A3");
			//Assert.IsTrue (String.Empty != item.GetMetadata ("RootDir"), "A4");
			Assert.AreEqual (itemInclude, item.GetMetadata ("Filename"), "A5");
			Assert.AreEqual (String.Empty, item.GetMetadata ("Extension"), "A6");
			Assert.AreEqual (String.Empty, item.GetMetadata ("RelativeDir"), "A7");
			Assert.IsTrue (String.Empty != item.GetMetadata ("Directory"), "A8");
			Assert.AreEqual (String.Empty, item.GetMetadata ("RecursiveDir"), "A9");
			Assert.AreEqual (itemInclude, item.GetMetadata ("Identity"), "A10");
			// FIXME: test with CreatedTime
			Assert.AreEqual (String.Empty, item.GetMetadata ("ModifiedTime"), "A11");
			Assert.AreEqual (String.Empty, item.GetMetadata ("ModifiedTime"), "A12");
			Assert.AreEqual (String.Empty, item.GetMetadata ("AccessedTime"), "A13");
		}
Example #21
0
		public void TestGetEvaluatedMetadata1 ()
		{
			string itemName = "a";
			string itemInclude = "a";
			string metadataName = "name";
			string metadataValue = "a;b;c";

			item = new BuildItem (itemName, itemInclude);

			Assert.AreEqual (String.Empty, item.GetEvaluatedMetadata (metadataName), "A1");

			item.SetMetadata (metadataName, metadataValue);

			Assert.AreEqual (metadataValue, item.GetEvaluatedMetadata (metadataName), "A2");
			Assert.AreEqual (itemInclude, item.GetEvaluatedMetadata ("Identity"), "A3");
		}
Example #22
0
        public void PropertyFunctionConsumingItemMetadata()
        {
            MockLogger logger = new MockLogger();
            Project project = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`3.5` xmlns=`msbuildnamespace`>
                </Project>
            ", logger);


            BuildPropertyGroup pg = new BuildPropertyGroup();
            pg.SetProperty("SomePath", @"c:\some\path");

            BuildItemGroup ig = new BuildItemGroup();
            BuildItem item = new BuildItem("Compile", "fOo.Cs");
            item.SetMetadata("SomeMeta", "fOo.Cs");
            ig.AddItem(item);

            Hashtable itemsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);
            itemsByType["Compile"] = ig;

            Expander expander = new Expander(pg, itemsByType, ExpanderOptions.ExpandAll);
            expander.SetMetadataInMetadataTable("Compile", "SomeMeta", "fOo.Cs");

            string result = expander.ExpandAllIntoStringLeaveEscaped(@"$([System.IO.Path]::Combine($(SomePath),%(Compile.SomeMeta)))", null);

            Assertion.AssertEquals(@"c:\some\path\fOo.Cs", result);
        }
Example #23
0
		public void TestRemoveMetadata1 ()
		{
			string itemName = "a";
			string itemInclude = "a";
			string metadataName = "name";
			string metadataValue = "a;b;c";

			item = new BuildItem (itemName, itemInclude);

			item.SetMetadata (metadataName, metadataValue);

			Assert.AreEqual (true, item.HasMetadata (metadataName), "A1");

			item.RemoveMetadata (metadataName);

			Assert.AreEqual (false, item.HasMetadata (metadataName), "A2");
		}
Example #24
0
        public void CloneVirtual()
        {
            BuildItem item = new BuildItem("n", "i");
            item.SetMetadata("m1", "v1");
            item.SetMetadata("m2", "v2");
            BuildItem clone = item.Clone();

            Assertion.AssertEquals("v1", clone.GetMetadata("m1"));
            Assertion.AssertEquals("v2", clone.GetMetadata("m2"));

            clone.SetMetadata("m2", "newValue");

            Assertion.AssertEquals("v2", item.GetMetadata("m2"));
            Assertion.AssertEquals("newValue", clone.GetMetadata("m2"));
        }
Example #25
0
		public void TestSetMetadata3 ()
		{
			item = new BuildItem ("name", "include");
			item.SetMetadata ("a", "$(A)");
			item.SetMetadata ("b", "$(A)", true);
			item.SetMetadata ("c", "$(A)", false);

			Assert.AreEqual ("$(A)", item.GetEvaluatedMetadata ("a"), "A1");
			Assert.AreEqual ("$(A)", item.GetEvaluatedMetadata ("b"), "A2");
			Assert.AreEqual ("$(A)", item.GetEvaluatedMetadata ("c"), "A3");
			Assert.AreEqual ("$(A)", item.GetMetadata ("a"), "A4");
			Assert.AreEqual (Utilities.Escape ("$(A)"), item.GetMetadata ("b"), "A5");
			Assert.AreEqual ("$(A)", item.GetMetadata ("c"), "A6");
		}
Example #26
0
        /// <summary>
        /// Loops through all of the Escape Characters to ensure the expected 'ArgumentException'
        ///     is thrown and that the exception message contains the Escape Character.  If any
        ///     unexpected exceptions are thrown, they are not directly handled, thus will fail the calling
        ///     unit test with the exception information.  And, if no exception is thrown, Assertion.Fail
        ///     is called, because the ArgumentException should have been thrown.
        /// </summary>
        /// <param name="testType">Type of test that you are calling from</param>
        private void VerifyEscapeCharactersThrowExpectedException(TypeOfTest testType)
        {
            foreach (char c in EscapableCharacters)
            {
                try
                {
                    if (testType == TypeOfTest.ConstructorTest)
                    {
                        BuildItem item = new BuildItem(c.ToString(), "i");
                    }
                    else if (testType == TypeOfTest.SetNameTest)
                    {
                        BuildItem item = new BuildItem("n", "i");
                        item.Name = c.ToString();
                    }
                    else if (testType == TypeOfTest.SetMetadataTest)
                    {
                        BuildItem item = new BuildItem("n", "i");
                        item.SetMetadata(c.ToString(), "v");
                    }

                    Assertion.Fail(String.Format("Escape Character '{0}' didn't throw the expected ArgumentException", c.ToString()));
                }
                catch (ArgumentException expected)
                {
                    Assertion.AssertEquals(true, expected.Message.Contains(c.ToString()));
                }
            }
        }
Example #27
0
        /// <summary>
        /// Copies all custom attributes to given item.
        /// </summary>
        /// <param name="destinationItem">BuildItem to copy custom attributes to</param>
        public void CopyCustomMetadataTo(BuildItem destinationItem)
        {
            ErrorUtilities.VerifyThrowArgumentNull(destinationItem, "destinationItem");

            if (IsBackedByXml)
            {
                List<XmlElement> children = xml.GetChildren();

                foreach (XmlElement child in children)
                {
                    destinationItem.SetMetadata(child.Name, child.InnerXml);
                }
            }
            else
            {
                ErrorUtilities.VerifyThrow(this.evaluatedCustomMetadata != null, "Item not initialized properly.");

                foreach (DictionaryEntry customAttributeEntry in this.evaluatedCustomMetadata)
                {
                    destinationItem.SetMetadata((string)customAttributeEntry.Key, (string)customAttributeEntry.Value);
                }
            }
        }
Example #28
0
 public void InvalidItemMetadataNameRename()
 {
     bool fExceptionCaught = false;
     BuildItem item = new BuildItem("my", "precioussss");
     try
     {
         item.SetMetadata("Choose", "blah");
     }
     catch (InvalidOperationException)
     {
         fExceptionCaught = true;
     }
     Assertion.Assert(fExceptionCaught);
 }
Example #29
0
        public void SetMetadataSimple()
        {
            BuildItem item = new BuildItem("n", "i");
            item.SetMetadata("m", "v");

            Assertion.AssertEquals(true, item.HasMetadata("m"));
            Assertion.AssertEquals("v", item.GetMetadata("m"));
        }
Example #30
0
        public void IsEquivalentTaskItem()
        {
            BuildItem bi = new BuildItem("itemname", "itemspec");
            bi.SetMetadata("mn", "mv");

            BuildItemCacheEntry e = new BuildItemCacheEntry("name", new BuildItem[] { bi });

            Assert.IsFalse(e.IsEquivalent(null));
            Assert.IsFalse(e.IsEquivalent(new PropertyCacheEntry()));
            Assert.IsFalse(e.IsEquivalent(new BuildItemCacheEntry()));
            Assert.IsFalse(e.IsEquivalent(new BuildItemCacheEntry("naame", new BuildItem[] { bi })));
            Assert.IsFalse(e.IsEquivalent(new BuildItemCacheEntry("name", null)));
            Assert.IsFalse(e.IsEquivalent(new BuildItemCacheEntry("name", new BuildItem[] { null })));
            Assert.IsFalse(new BuildItemCacheEntry("name", new BuildItem[] { null }).IsEquivalent(e));
            Assert.IsFalse(e.IsEquivalent(new BuildItemCacheEntry("name", new BuildItem[] { new BuildItem("itemname", "itemspec") })));
            Assert.IsFalse(e.IsEquivalent(new BuildItemCacheEntry("name", new BuildItem[] { bi, bi })));

            BuildItem bi2 = new BuildItem("itemname", "itemspec");
            bi2.SetMetadata("n", "v");
            Assert.IsFalse(e.IsEquivalent(new BuildItemCacheEntry("name", new BuildItem[] { bi2 })));
            bi2.SetMetadata("mn", "mv");
            Assert.IsFalse(e.IsEquivalent(new BuildItemCacheEntry("name", new BuildItem[] { bi2 })));

            BuildItem bi3 = new BuildItem("itemname", "itemspec");
            bi3.SetMetadata("mn", "mv");
            Assert.IsTrue(e.IsEquivalent(new BuildItemCacheEntry("name", new BuildItem[] { bi3 })));
        }
Example #31
0
        /// <summary>
        /// Loops through all of the Reserved itemNames to ensure the expected 'InvalidOperationException'
        ///     is thrown and that the exception message contains the reserved itemName name.  If any
        ///     unexpected exceptions are thrown, they are not directly handled, thus will fail the calling
        ///     unit test with the exception information.  And, if no exception is thrown, Assertion.Fail
        ///     is called, because the InvalidOperationException should have been thrown.
        /// </summary>
        /// <param name="testType">Type of test that you are calling from</param>
        private void VerifyReservedNamesForBuildItemNameThrowExpectedException(TypeOfTest testType)
        {
            foreach (string s in reservedNames)
            {
                try
                {
                    if (testType == TypeOfTest.ConstructorTest)
                    {
                        BuildItem item = new BuildItem(s, "i");
                    }
                    else if (testType == TypeOfTest.SetNameTest)
                    {
                        BuildItem item = new BuildItem("n", "i");
                        item.Name = s;
                    }
                    else if (testType == TypeOfTest.SetMetadataTest)
                    {
                        BuildItem item = new BuildItem("n", "i");
                        item.SetMetadata(s, "v");
                    }

                    Assertion.Fail(String.Format("Reserved itemName '{0}' didn't throw the expected InvalidOperationException", s));
                }
                catch (InvalidOperationException expected)
                {
                    Assertion.AssertEquals(true, expected.Message.Contains(s));
                }
            }
        }
Example #32
0
		public void TestClone1 ()
		{
			item = new BuildItem ("name", "1;2;3");
			item.SetMetadata ("a", "b");

			BuildItem item2 = item.Clone ();

			Assert.AreEqual ("1;2;3", item2.FinalItemSpec, "A1");
			Assert.AreEqual ("1;2;3", item2.Include, "A2");
			Assert.AreEqual (String.Empty, item2.Exclude, "A3");
			Assert.AreEqual (String.Empty, item2.Condition, "A4");
			Assert.AreEqual (false, item2.IsImported, "A5");
			Assert.AreEqual ("name", item2.Name, "A6");
		}
Example #33
0
 protected override void OnAddResource(BuildItem item)
 {
     item.SetMetadata("CustomToolNamespace", "My.Resources");
     item.SetMetadata("Generator", "VbMyResourcesResXFileCodeGenerator");
 }
Example #34
0
        public override void Execute()
        {
            if (!(hostContext.Data["EnabledRenderers"] as StringCollection).Contains(this.Identifier))
            {
                return;
            }

            // Get parameters
            Dictionary <String, StringCollection> parameters = hostContext.Data["CommandParameters"] as Dictionary <String, StringCollection>;

            System.Diagnostics.Trace.WriteLine("\r\nStarting RIMBA Renderer", "information");
            StringCollection genFormatters = new StringCollection();
            bool             makeWP7Proj   = false;

            if (hostContext.Mode == Pipeline.OperationModeType.Quirks)
            {
                System.Diagnostics.Trace.WriteLine("--- WARNING ---\r\n Host context is operating in Quirks mode, GPMR cannot guarantee output will be accurate\r\n--- WARNING ---");
            }

            #region Validate all parameters
            // Validate parameters
            if (!parameters.ContainsKey("rimbapi-api-ns"))
            {
                parameters.Add("rimbapi-api-ns", new StringCollection());
                parameters["rimbapi-api-ns"].Add("MARC.Everest");
            }
            if (!parameters.ContainsKey("rimbapi-target-ns"))
            {
                parameters.Add("rimbapi-target-ns", new StringCollection());
                parameters["rimbapi-target-ns"].Add("output");
            }
            if (parameters.ContainsKey("rimbapi-root-class"))
            {
                RootClass = parameters["rimbapi-root-class"][0];
            }
            if (parameters.ContainsKey("rimbapi-gen-vocab"))
            {
                GenerateVocab = Convert.ToBoolean(parameters["rimbapi-gen-vocab"][0]);
            }
            if (parameters.ContainsKey("rimbapi-gen-rim"))
            {
                GenerateRim = Convert.ToBoolean(parameters["rimbapi-gen-rim"][0]);
            }
            if (parameters.ContainsKey("rimbapi-profileid"))
            {
                InteractionRenderer.profileId = parameters["rimbapi-profileid"][0];
            }
            if (parameters.ContainsKey("rimbapi-oid-profileid"))
            {
                InteractionRenderer.profileIdOid = parameters["rimbapi-oid-profileid"][0];
            }
            if (parameters.ContainsKey("rimbapi-oid-interactionid"))
            {
                InteractionRenderer.interactionIdOid = parameters["rimbapi-oid-interactionid"][0];
            }
            if (parameters.ContainsKey("rimbapi-oid-triggerevent"))
            {
                InteractionRenderer.triggerEventOid = parameters["rimbapi-oid-triggerevent"][0];
            }
            if (parameters.ContainsKey("rimbapi-gen-its"))
            {
                genFormatters = parameters["rimbapi-gen-its"];
            }
            if (parameters.ContainsKey("rimbapi-phone"))
            {
                makeWP7Proj = bool.Parse(parameters["rimbapi-phone"][0]);
            }

            #endregion

            // Initialize Heuristics
            MohawkCollege.EHR.gpmr.Pipeline.Renderer.RimbaCS.HeuristicEngine.Datatypes.Initialize(parameters["rimbapi-api-ns"][0]);
            MohawkCollege.EHR.gpmr.Pipeline.Renderer.RimbaCS.HeuristicEngine.Interfaces.Initialize(parameters["rimbapi-api-ns"][0]);

            // Get our repository ready
            ClassRepository classRep = hostContext.Data["SourceCR"] as ClassRepository;

            string ProjectFileName = "output.csproj"; // Set the output file name
            if (parameters.ContainsKey("rimbapi-target-ns"))
            {
                ProjectFileName = parameters["rimbapi-target-ns"][0];
            }
            if (parameters.ContainsKey("rimbapi-partials"))
            {
                RenderPartials = Boolean.Parse(parameters["rimbapi-partials"][0]);
            }
            if (parameters.ContainsKey("rimbapi-realm-pref"))
            {
                prefRealm = parameters["rimbapi-realm-pref"][0];
            }
            if (parameters.ContainsKey("rimbapi-max-literals"))
            {
                MaxLiterals = Int32.Parse(parameters["rimbapi-max-literals"][0]);
            }
            if (parameters.ContainsKey("rimbapi-suppress-doc"))
            {
                SuppressDoc = Boolean.Parse(parameters["rimbapi-suppress-doc"][0]);
            }
            // Setup the template parameters
            string[][] templateFields = new string[][]
            {
                new string[] { "$license$", parameters.ContainsKey("rimbapi-license") ? Licenses.ResourceManager.GetString(parameters["rimbapi-license"][0].ToUpper()) : "" },
                new string[] { "$org$", parameters.ContainsKey("rimbapi-org") ? parameters["rimbapi-org"][0] : "" },
                new string[] { "$date$", DateTime.Now.ToString("yyyy-MM-dd") },
                new string[] { "$clrversion$", Environment.Version.ToString() },
                new string[] { "$time$", DateTime.Now.ToString("HH:mm:ss") },
                new string[] { "$author$", SystemInformation.UserName },
                new string[] { "$year$", DateTime.Now.Year.ToString() },
                new string[] { "$version$", Assembly.GetEntryAssembly().GetName().Version.ToString() },
                new string[] { "$guid$", Guid.NewGuid().ToString() },
                new string[] { "$name$", ProjectFileName },
                new string[] { "$mrversion$", InteractionRenderer.profileId ?? "" }
            };

            // Now we want to scan our assembly for FeatureRenderers
            List <KeyValuePair <FeatureRendererAttribute, IFeatureRenderer> > renderers = new List <KeyValuePair <FeatureRendererAttribute, IFeatureRenderer> >();
            foreach (Type t in this.GetType().Assembly.GetTypes())
            {
                if (t.GetInterface("MohawkCollege.EHR.gpmr.Pipeline.Renderer.RimbaCS.Interfaces.IFeatureRenderer") != null &&
                    t.GetCustomAttributes(typeof(FeatureRendererAttribute), true).Length > 0)
                {
                    foreach (FeatureRendererAttribute feature in (t.GetCustomAttributes(typeof(FeatureRendererAttribute), true)))
                    {
                        // Only one feature renderer per feature, so if the dictionary throws an exception
                        // on the add it is ok
                        renderers.Add(new KeyValuePair <FeatureRendererAttribute, IFeatureRenderer>(feature, (IFeatureRenderer)t.Assembly.CreateInstance(t.FullName)));
                    }
                }
            }

            #region Setup the project
            // Create engine reference
            Microsoft.Build.BuildEngine.Engine engine = new Microsoft.Build.BuildEngine.Engine(
                Path.Combine(Path.Combine(Path.Combine(System.Environment.SystemDirectory, "..\\Microsoft.NET"), "Framework"), "v3.5")),
                                               phoneEngine = new Microsoft.Build.BuildEngine.Engine(
                Path.Combine(Path.Combine(Path.Combine(System.Environment.SystemDirectory, "..\\Microsoft.NET"), "Framework"), "v4.0.30319"));

            // Create MSPROJ
            Microsoft.Build.BuildEngine.Project project   = new Microsoft.Build.BuildEngine.Project(engine),
                                                phoneProj = new Project(phoneEngine, "4.0");


            phoneProj.DefaultTargets = project.DefaultTargets = "Build";


            // Setup project attributes
            Microsoft.Build.BuildEngine.BuildPropertyGroup pg = project.AddNewPropertyGroup(false);

            Microsoft.Build.BuildEngine.BuildProperty property = pg.AddNewProperty("Configuration", "Release");

            property.Condition = "'$(Configuration)' == ''";
            property           = pg.AddNewProperty("Platform", "AnyCPU");
            property.Condition = "'$(Platform)' == ''";
            pg.AddNewProperty("ProductVersion", "10.0.20506");
            pg.AddNewProperty("SchemaVersion", "2.0");
            pg.AddNewProperty("ProjectGuid", Guid.NewGuid().ToString());
            pg.AddNewProperty("OutputType", "Library");
            pg.AddNewProperty("AppDesignerFolder", "Properties");
            pg.AddNewProperty("RootNamespace", parameters["rimbapi-target-ns"][0]);
            pg.AddNewProperty("AssemblyName", parameters["rimbapi-target-ns"][0]);

            // Release AnyCPU
            pg           = project.AddNewPropertyGroup(false);
            pg.Condition = "'$(Configuration)|$(Platform)' == 'Release|AnyCPU'";
            pg.AddNewProperty("DebugType", "pdbonly");
            pg.AddNewProperty("Optimize", "true");
            pg.AddNewProperty("OutputPath", "bin\\release");
            pg.AddNewProperty("DefineConstants", "TRACE");
            pg.AddNewProperty("ErrorReport", "prompt");
            pg.AddNewProperty("WarningLevel", "4");
            pg.AddNewProperty("DocumentationFile", "bin\\release\\" + parameters["rimbapi-target-ns"][0] + ".xml");

            // Create Dir Structure
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "bin"));
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "lib"));
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "Properties"));
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "Vocabulary"));
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "Interaction"));

            // Add reference structure
            Microsoft.Build.BuildEngine.BuildItemGroup refItemGroup = project.AddNewItemGroup();

            // Add References
            File.Copy(Path.Combine(System.Windows.Forms.Application.StartupPath, "MARC.Everest.dll"), Path.Combine(Path.Combine(hostContext.Output, "lib"), "MARC.Everest.dll"), true);

            if (makeWP7Proj)
            {
                File.Copy(Path.Combine(Path.Combine(System.Windows.Forms.Application.StartupPath, "lib"), "MARC.Everest.Phone.dll"), Path.Combine(Path.Combine(hostContext.Output, "lib"), "MARC.Everest.Phone.dll"), true);
            }

            File.Copy(Path.Combine(System.Windows.Forms.Application.StartupPath, "MARC.Everest.xml"), Path.Combine(Path.Combine(hostContext.Output, "lib"), "MARC.Everest.xml"), true);
            refItemGroup.AddNewItem("Reference", "System");
            refItemGroup.AddNewItem("Reference", "System.Drawing");
            refItemGroup.AddNewItem("Reference", "System.Xml");
            Microsoft.Build.BuildEngine.BuildItem buildItem = refItemGroup.AddNewItem("Reference", @"MARC.Everest");
            buildItem.SetMetadata("SpecificVersion", "false");
            buildItem.SetMetadata("HintPath", "lib\\MARC.Everest.dll");

            project.AddNewImport("$(MSBuildBinPath)\\Microsoft.CSharp.targets", null);

            Microsoft.Build.BuildEngine.BuildItemGroup fileItemGroup      = project.AddNewItemGroup(),
                                                       phoneFileItemGroup = phoneProj.AddNewItemGroup();

            #region Assembly Info
            try
            {
                TextWriter tw = File.CreateText(Path.Combine(Path.Combine(hostContext.Output, "Properties"), "AssemblyInfo.cs"));
                try
                {
                    string Header = Template.AssemblyInfo; // Set the header to the default

                    // Populate template fields
                    foreach (String[] st in templateFields)
                    {
                        Header = Header.Replace(st[0], st[1]);
                    }

                    // Write header
                    tw.Write(Header);
                }
                finally
                {
                    tw.Close();
                }
                fileItemGroup.AddNewItem("Compile", Path.Combine("Properties", "AssemblyInfo.cs"));
                phoneFileItemGroup.AddNewItem("Compile", Path.Combine("Properties", "AssemblyInfo.cs"));
            }
            catch (Exception)
            {
                System.Diagnostics.Trace.WriteLine("Couldn't generate the AssemblyInfo.cs file for this project", "warn");
            }
            #endregion
            #endregion

            #region Code Create
            // Convert class rep to list
            List <Feature> features = new List <Feature>();
            foreach (KeyValuePair <String, Feature> kv in classRep)
            {
                features.Add(kv.Value);
            }
            // Sort so classes are processed first
            features.Sort(delegate(Feature a, Feature b)
            {
                if ((a is SubSystem) && !(b is SubSystem))
                {
                    return(-1);
                }
                else if ((b is SubSystem) && !(a is SubSystem))
                {
                    return(1);
                }
                else
                {
                    return(a.GetType().Name.CompareTo(b.GetType().Name));
                }
            });

            RenderFeatureList(features, templateFields, renderers, fileItemGroup, phoneFileItemGroup, parameters);

            // Any added features?
            // HACK: This should be fixed soon, but meh... I'll get around to it
            List <Feature> addlFeatures = new List <Feature>();
            foreach (KeyValuePair <String, Feature> kv in classRep)
            {
                if (!features.Contains(kv.Value))
                {
                    addlFeatures.Add(kv.Value);
                }
            }
            RenderFeatureList(addlFeatures, templateFields, renderers, fileItemGroup, phoneFileItemGroup, parameters);

            // Save the project
            project.Save(Path.Combine(hostContext.Output, ProjectFileName) + ".csproj");
            #endregion

            // Compile?
            #region Compile this project

            // Does the user want to compile?
            if (parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-compile"][0]))
            {
                string logPath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); // Create log
                Microsoft.Build.BuildEngine.FileLogger logger = new Microsoft.Build.BuildEngine.FileLogger();
                logger.Parameters = "logfile=" + logPath;
                engine.RegisterLogger(logger);

                System.Diagnostics.Trace.Write(String.Format("Compiling project (Build log {0})...", logPath), "information");

                // Compile
                if (engine.BuildProject(project))
                {
                    System.Diagnostics.Trace.WriteLine("Success!", "information");
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("Fail", "information");
                    throw new InvalidOperationException("Failed compilation, operation cannot continue");
                }
                engine.UnregisterAllLoggers();
            }
            #endregion

            #region Windows Phone

            if (makeWP7Proj)
            {
                // Setup project attributes
                pg                 = phoneProj.AddNewPropertyGroup(false);
                property           = pg.AddNewProperty("Configuration", "Release");
                property.Condition = "'$(Configuration)' == ''";
                property           = pg.AddNewProperty("Platform", "AnyCPU");
                property.Condition = "'$(Platform)' == ''";
                pg.AddNewProperty("ProductVersion", "10.0.20506");
                pg.AddNewProperty("SchemaVersion", "2.0");
                pg.AddNewProperty("ProjectGuid", Guid.NewGuid().ToString());
                pg.AddNewProperty("OutputType", "Library");
                pg.AddNewProperty("AppDesignerFolder", "Properties");
                pg.AddNewProperty("RootNamespace", parameters["rimbapi-target-ns"][0]);
                pg.AddNewProperty("AssemblyName", parameters["rimbapi-target-ns"][0] + ".Phone");
                pg.AddNewProperty("ProjectTypeGuids", "{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}");
                pg.AddNewProperty("TargetFrameworkVersion", "v4.0");
                pg.AddNewProperty("SilverlightVersion", "$(TargetFrameworkVersion)");
                pg.AddNewProperty("TargetFrameworkProfile", "WindowsPhone71");
                pg.AddNewProperty("TargetFrameworkIdentifier", "Silverlight");
                pg.AddNewProperty("SilverlightApplication", "false");
                pg.AddNewProperty("ValidateXaml", "true");
                pg.AddNewProperty("ThrowErrorsInValidation", "true");

                // Release AnyCPU
                pg           = phoneProj.AddNewPropertyGroup(false);
                pg.Condition = "'$(Configuration)|$(Platform)' == 'Release|AnyCPU'";
                pg.AddNewProperty("DebugType", "pdbonly");
                pg.AddNewProperty("Optimize", "true");
                pg.AddNewProperty("OutputPath", "bin\\release");
                pg.AddNewProperty("DefineConstants", "TRACE;SILVERLIGHT;WINDOWS_PHONE");
                pg.AddNewProperty("ErrorReport", "prompt");
                pg.AddNewProperty("NoStdLib", "true");
                pg.AddNewProperty("NoConfig", "true");
                pg.AddNewProperty("WarningLevel", "4");
                pg.AddNewProperty("DocumentationFile", "bin\\release\\" + parameters["rimbapi-target-ns"][0] + ".Phone.xml");

                // Add reference structure
                refItemGroup = phoneProj.AddNewItemGroup();
                refItemGroup.AddNewItem("Reference", "System");
                refItemGroup.AddNewItem("Reference", "System.Xml");

                BuildItem evReference = refItemGroup.AddNewItem("Reference", @"MARC.Everest.Phone");
                evReference.SetMetadata("SpecificVersion", "false");
                evReference.SetMetadata("HintPath", "lib\\MARC.Everest.Phone.dll");

                // Add WP7 Imports
                phoneProj.AddNewImport(@"$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets", null);
                phoneProj.AddNewImport(@"$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets", null);

                // HACK: Add tools version
                string fileName = Path.Combine(hostContext.Output, ProjectFileName) + ".Phone.csproj";
                phoneProj.Save(fileName);
                XmlDocument doc = new XmlDocument();
                doc.Load(fileName);
                doc.DocumentElement.Attributes.Append(doc.CreateAttribute("ToolsVersion"));
                doc.DocumentElement.Attributes["ToolsVersion"].Value = "4.0";
                doc.Save(fileName);

                if (parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-compile"][0]))
                {
                    System.Diagnostics.Trace.Write(String.Format("Compiling phone project..."), "information");

                    // Compile
                    if (phoneEngine.BuildProjectFile(fileName))
                    {
                        System.Diagnostics.Trace.WriteLine("Success!", "information");
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine("Fail", "information");
                        throw new InvalidOperationException("Failed compilation, operation cannot continue");
                    }
                }
            }

            #endregion

            #region Generate Formatter Assemblies

            // Generate the formatter assemblies
            if (genFormatters.Count > 0 && parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-compile"][0]))
            {
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                Trace.WriteLine("Generating ITS Formatter Types:", "information");

                // Load the assembly
                Assembly genAsm = Assembly.LoadFile(Path.Combine(Path.Combine(Path.Combine(hostContext.Output, "bin"), "release"), ProjectFileName + ".dll"));
                foreach (string s in genFormatters)
                {
                    GenerateFormatterAssembly(s, genAsm, InteractionRenderer.profileId ?? "formatter");
                }

                // Assembly resolve
                AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            }
            else if (genFormatters.Count > 0)
            {
                Trace.WriteLine("Can't use --rimbapi-gen-its when --rimbapi-compile is not true, skipping ITS generation", "warn");
            }
            #endregion

            // Does the user only want asm?
            #region dllonly
            if (parameters.ContainsKey("rimbapi-dllonly") && parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-dllonly"][0]))
            {
                try
                {
                    // Move the assemblies up to root
                    foreach (string file in Directory.GetFiles(Path.Combine(Path.Combine(hostContext.Output, "bin"), "release")))
                    {
                        if (File.Exists(Path.Combine(hostContext.Output, Path.GetFileName(file))))
                        {
                            File.Delete(Path.Combine(hostContext.Output, Path.GetFileName(file)));
                        }
                        File.Move(file, Path.Combine(hostContext.Output, Path.GetFileName(file)));
                    }

                    // Clean all in the projects and remove all directories
                    List <String> directories = new List <string>(new string[] {
                        Path.Combine(Path.Combine(hostContext.Output, "bin"), "release"),
                        Path.Combine(hostContext.Output, "bin"),
                        Path.Combine(hostContext.Output, "lib"),
                        Path.Combine(hostContext.Output, "Vocabulary"),
                        Path.Combine(hostContext.Output, "Interaction"),
                        Path.Combine(hostContext.Output, "obj")
                    });

                    // Gather files and clean
                    foreach (Microsoft.Build.BuildEngine.BuildItem fi in fileItemGroup)
                    {
                        // Add directory on the "to be deleted"
                        string dirName = Path.GetDirectoryName(Path.Combine(hostContext.Output, fi.Include));
                        if (!directories.Contains(dirName))
                        {
                            directories.Add(dirName);
                        }

                        Trace.WriteLine(String.Format("Deleting {0}...", fi.Include), "debug");
                        File.Delete(Path.Combine(hostContext.Output, fi.Include));
                    }
                    // Clean dirs
                    foreach (string s in directories)
                    {
                        Directory.Delete(s, true);
                    }
                    File.Delete(project.FullFileName);
                }
                catch (Exception)
                {
                    System.Diagnostics.Trace.WriteLine("Could not clean working files!", "warn");
                }
            }
            #endregion
        }