Esempio n. 1
0
        public void how_to_convert_DTE_ProjectItem_to_MSBuild_ProjectItem()
        {
            // Say you got a DTE project item somehow.
            EnvDTE.ProjectItem dteItem = this.DteLibrary.ProjectItems.OfType <EnvDTE.ProjectItem>().First(pi => pi.Name == "Class1.cs");

            Microsoft.Build.Evaluation.ProjectItem item = dteItem.Adapt().AsMsBuildItem();

            Assert.IsNotNull(item);

            // Now use MSBuild to set/get custom metadata on the item
            item.SetMetadataValue("Identifier", "Foo");
            string identifier = item.GetMetadataValue("Identifier");

            Assert.AreEqual("Foo", identifier);
        }
Esempio n. 2
0
        public void how_to_convert_DTE_ProjectItem_to_IItemNode()
        {
            // Say you got a DTE project item somehow.
            EnvDTE.ProjectItem dteItem = this.DteLibrary.ProjectItems.OfType <EnvDTE.ProjectItem>().First(pi => pi.Name == "Class1.cs");

            IItemNode itemNode = dteItem.Adapt().AsItemNode();

            Assert.IsNotNull(itemNode);

            // Now we can use Clide's item node API, such as setting an
            // arbitrary MSBuild item metadata property using dynamic syntax.
            // This example sets the custom tool for the item to be MSBuild:Compile.
            itemNode.Properties.Generator = "MSBuild:Compile";

            Assert.AreEqual("MSBuild:Compile", (string)itemNode.Properties.Generator);
        }