当前位置: 首页>>代码示例>>C#>>正文


C# Project.RemoveItems方法代码示例

本文整理汇总了C#中Microsoft.Build.Evaluation.Project.RemoveItems方法的典型用法代码示例。如果您正苦于以下问题:C# Project.RemoveItems方法的具体用法?C# Project.RemoveItems怎么用?C# Project.RemoveItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.Evaluation.Project的用法示例。


在下文中一共展示了Project.RemoveItems方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Cleanup

        private static void Cleanup(Project project, string itemTypeToCleanup)
        {
            var items = project.Items.Where(x => x.ItemType == itemTypeToCleanup).ToList();
            project.RemoveItems(items);

            var sortedItems = items.OrderBy(x => x.UnevaluatedInclude);

            foreach (var item in sortedItems)
                project.AddItemFast(itemTypeToCleanup, item.UnevaluatedInclude);
        }
开发者ID:exira,项目名称:csproj-rewriter,代码行数:10,代码来源:Program.cs

示例2: TestRunPythonCommand

        public void TestRunPythonCommand() {
            var expectedSearchPath = string.Format("['{0}', '{1}']",
                TestData.GetPath(@"TestData").Replace("\\", "\\\\"),
                TestData.GetPath(@"TestData\HelloWorld").Replace("\\", "\\\\")
            );

            var proj = new Project(TestData.GetPath(@"TestData\Targets\Commands4.pyproj"));

            foreach (var version in PythonPaths.Versions) {
                var verStr = version.Version.ToVersion().ToString();
                proj.SetProperty("InterpreterId", version.Id.ToString("B"));
                proj.SetProperty("InterpreterVersion", verStr);
                proj.RemoveItems(proj.ItemsIgnoringCondition.Where(i => i.ItemType == "InterpreterReference").ToArray());
                proj.AddItem("InterpreterReference", string.Format("{0:B}\\{1}", version.Id, verStr));
                proj.Save();
                proj.ReevaluateIfNecessary();

                var log = new StringLogger(LoggerVerbosity.Minimal);
                Assert.IsTrue(proj.Build("CheckCode", new ILogger[] { new ConsoleLogger(LoggerVerbosity.Detailed), log }));
                
                Console.WriteLine();
                Console.WriteLine("Output from {0:B} {1}", version.Id, version.Version.ToVersion());
                foreach (var line in log.Lines) {
                    Console.WriteLine("* {0}", line.TrimEnd('\r', '\n'));
                }

                var logLines = log.Lines.Last().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                Assert.AreEqual(2, logLines.Length);
                Assert.AreEqual(version.Version.ToVersion().ToString(), logLines[0].Trim());
                Assert.AreEqual(expectedSearchPath, logLines[1].Trim());
            }
        }
开发者ID:sadapple,项目名称:PTVS,代码行数:32,代码来源:BuildTasksTests.cs

示例3: RemoveZombiedItem

        public void RemoveZombiedItem()
        {
            string projectOriginalContents = ObjectModelHelpers.CleanupFileContents(@"
                <Project ToolsVersion='msbuilddefaulttoolsversion' DefaultTargets='Build' xmlns='msbuildnamespace'>
                    <ItemGroup>
                        <i Include='i1' />
                    </ItemGroup>
                </Project>
                ");
            Project project = new Project(XmlReader.Create(new StringReader(projectOriginalContents)));
            ProjectItem item = project.GetItems("i").FirstOrDefault();

            project.RemoveItems(new List<ProjectItem>() { item });
            project.RemoveItems(new List<ProjectItem>() { item });

            Assert.Equal(0, project.Items.Count());
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:17,代码来源:Project_Tests.cs

示例4: RemoveItemWrongProject

        public void RemoveItemWrongProject()
        {
            Assert.Throws<ArgumentException>(() =>
            {
                ProjectRootElement root1 = ProjectRootElement.Create();
                root1.AddItem("i", "i1");
                ProjectRootElement root2 = ProjectRootElement.Create();
                root2.AddItem("i", "i1");
                Project project1 = new Project(root1);
                Project project2 = new Project(root2);

                project1.RemoveItems(project2.Items);
            }
           );
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:15,代码来源:Project_Tests.cs

示例5: RemoveItemsOneNull

 public void RemoveItemsOneNull()
 {
     Assert.Throws<ArgumentNullException>(() =>
     {
         Project project = new Project();
         project.RemoveItems(new List<ProjectItem>() { null });
     }
    );
 }
开发者ID:cameron314,项目名称:msbuild,代码行数:9,代码来源:Project_Tests.cs

示例6: RemoveSeveralItemsExpandExpression

        public void RemoveSeveralItemsExpandExpression()
        {
            string projectOriginalContents = ObjectModelHelpers.CleanupFileContents(@"
                <Project ToolsVersion='msbuilddefaulttoolsversion' DefaultTargets='Build' xmlns='msbuildnamespace'>
                    <ItemGroup>
                        <i Include='i1;i2' />
                        <j Include='@(i);j2' />
                    </ItemGroup>
                </Project>
                ");
            Project project = new Project(XmlReader.Create(new StringReader(projectOriginalContents)));

            project.RemoveItems(project.GetItems("j").Take(2));
            Assert.Equal(3, project.Items.Count());

            StringWriter writer = new StringWriter();
            project.Save(writer);

            string projectExpectedContents = ObjectModelHelpers.CleanupFileContents(@"
                <Project ToolsVersion='msbuilddefaulttoolsversion' DefaultTargets='Build' xmlns='msbuildnamespace'>
                    <ItemGroup>
                        <i Include='i1;i2' />
                        <j Include='j2' />
                    </ItemGroup>
                </Project>
                ");

            Helpers.CompareProjectXml(projectExpectedContents, writer.ToString());
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:29,代码来源:Project_Tests.cs

示例7: RemoveSeveralItemsOfVariousTypes

        public void RemoveSeveralItemsOfVariousTypes()
        {
            string projectOriginalContents = ObjectModelHelpers.CleanupFileContents(@"
                <Project ToolsVersion='msbuilddefaulttoolsversion' DefaultTargets='Build' xmlns='msbuildnamespace'>
                    <ItemGroup>
                        <i Include='i1' />
                        <j Include='j1' />
                        <j Include='j2' />
                        <k Include='k1' />
                    </ItemGroup>
                </Project>
                ");
            Project project = new Project(XmlReader.Create(new StringReader(projectOriginalContents)));

            List<ProjectItem> list = new List<ProjectItem>() { project.GetItems("i").FirstOrDefault(), project.GetItems("j").FirstOrDefault() };

            project.RemoveItems(list);

            Assert.Equal(2, project.Items.Count());
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:20,代码来源:Project_Tests.cs

示例8: RemoveItemWrongProject

        public void RemoveItemWrongProject()
        {
            ProjectRootElement root1 = ProjectRootElement.Create();
            root1.AddItem("i", "i1");
            ProjectRootElement root2 = ProjectRootElement.Create();
            root2.AddItem("i", "i1");
            Project project1 = new Project(root1);
            Project project2 = new Project(root2);

            project1.RemoveItems(project2.Items);
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:11,代码来源:Project_Tests.cs

示例9: RemoveItemsOneNull

 public void RemoveItemsOneNull()
 {
     Project project = new Project();
     project.RemoveItems(new List<ProjectItem>() { null });
 }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:5,代码来源:Project_Tests.cs

示例10: RemoveSeveralItemsFirstZombiesSecond

        public void RemoveSeveralItemsFirstZombiesSecond()
        {
            string projectOriginalContents = ObjectModelHelpers.CleanupFileContents(@"
                <Project ToolsVersion='msbuilddefaulttoolsversion' DefaultTargets='Build' xmlns='msbuildnamespace'>
                    <ItemGroup>
                        <i Include='i1;i2' />
                    </ItemGroup>
                </Project>
                ");
            Project project = new Project(XmlReader.Create(new StringReader(projectOriginalContents)));

            project.RemoveItems(project.GetItems("i"));

            Assert.AreEqual(0, project.Items.Count());
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:15,代码来源:Project_Tests.cs

示例11: FixReferences

        private void FixReferences(Project project, Dictionary<ProjectItem, ReferenceConfig> referencesToRemove)
        {
            foreach (var referenceConfig in referencesToRemove.Values)
            {
                _processedReferences[referenceConfig] = true;
            }

            project.RemoveItems(referencesToRemove.Keys);
            foreach (var referenceToRemove in referencesToRemove.Values)
            {
                project.AddItem(ProjectStrings.AssemblyReference, referenceToRemove.AssemblyReference,
                    referenceToRemove.CreateMetaData(project.FullPath));
            }
        }
开发者ID:cebence,项目名称:Reffixer,代码行数:14,代码来源:ProjectManager.cs

示例12: ExcludePaths

	    private static void ExcludePaths(Project proj, IReadOnlyList<string> excludedPaths)
	    {
	        var toRemove = proj.Items.Where(item => excludedPaths.Contains(item.UnevaluatedInclude)).ToList();
	        proj.RemoveItems(toRemove);
        }
开发者ID:kontur-edu,项目名称:uLearn,代码行数:5,代码来源:ProjModifier.cs

示例13: RemoveCheckingFromCsproj

		public static void RemoveCheckingFromCsproj(Project proj)
		{
			var toRemove = proj.Items.Where(IsChecking).ToList();
			proj.RemoveItems(toRemove);
		}
开发者ID:kontur-edu,项目名称:uLearn,代码行数:5,代码来源:ProjModifier.cs


注:本文中的Microsoft.Build.Evaluation.Project.RemoveItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。