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


C# Project.RemovePropertyGroupsWithMatchingCondition方法代码示例

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


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

示例1: RemovePersistedImportedPropertyGroupMatchingCondition

        public void RemovePersistedImportedPropertyGroupMatchingCondition()
        {
            // Create temp files on disk for the main project file and the imported project file.
            string importedProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"

                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>

                        <PropertyGroup Condition=`'$(Configuration)' == 'Config1'`>
                            <Prop>FromUserFile1</Prop>
                        </PropertyGroup>
                        <PropertyGroup Condition=`'$(Configuration)' == 'Config2'`>
                            <Prop>FromUserFile2</Prop>
                        </PropertyGroup>
                        <PropertyGroup Condition=`'$(Configuration)' == 'Test'`>
                            <Prop>FromUserFileTest</Prop>
                        </PropertyGroup>

                    </Project>

                ");

            string mainProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"

                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                        <Import Project=`{0}`/>
                    </Project>

                ", importedProjFilename);

            try
            {
                // Load the two projects using the MSBuild object model.
                Project mainProj = new Project(new Engine(@"c:\"));
                Project importedProj = new Project(mainProj.ParentEngine);

                mainProj.Load(mainProjFilename);
                importedProj.Load(importedProjFilename);

                mainProj.RemovePropertyGroupsWithMatchingCondition("'$(Configuration)' == 'Test'", true /* include imported */);
                importedProj.RemovePropertyGroupsWithMatchingCondition("'$(Configuration)' == 'Test'", true /* include imported */);

                string[] configs = mainProj.GetConditionedPropertyValues("Configuration");

                Assertion.AssertEquals(2, configs.Length);
                Assertion.Assert(configs[0] == "Config1" || configs[1] == "Config1");
                Assertion.Assert(configs[0] == "Config2" || configs[1] == "Config2");
            }
            finally
            {
                File.Delete(mainProjFilename);
                File.Delete(importedProjFilename);
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:53,代码来源:Project_Tests.cs

示例2: RemovePropertyGroupsWithMatchingCondition_MatchInProject

 public void RemovePropertyGroupsWithMatchingCondition_MatchInProject()
 {
     string mainProjFilename = String.Empty;
     try
     {
         mainProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(TestData.PropertyGroup);
         Project mainProject = new Project(new Engine());
         mainProject.Load(mainProjFilename);
         Assertion.AssertEquals(1, mainProject.PropertyGroups.Count);
         mainProject.RemovePropertyGroupsWithMatchingCondition("true");
         Assertion.AssertEquals(0, mainProject.PropertyGroups.Count);
     }
     finally
     {
         CompatibilityTestHelpers.RemoveFile(mainProjFilename);
     }
 }
开发者ID:nikson,项目名称:msbuild,代码行数:17,代码来源:Project_Tests.cs

示例3: RemoveImportedPropertyGroupMatchingCondition

        public void RemoveImportedPropertyGroupMatchingCondition()
        {
            // Create temp files on disk for the main project file and the imported project file.
            string importedProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"

                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                    </Project>

                ");

            string mainProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"

                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                        <Import Project=`{0}`/>
                    </Project>

                ", importedProjFilename);

            try
            {
                // Load the two projects using the MSBuild object model.
                Project mainProj = new Project(new Engine(@"c:\"));
                Project importedProj = new Project(mainProj.ParentEngine);

                mainProj.Load(mainProjFilename);
                importedProj.Load(importedProjFilename);

                string configCondition1 = "'$(Configuration)' == 'Config1'";
                string configCondition2 = "'$(Configuration)' == 'Config2'";
                string configTestCondition = "'$(Configuration)' == 'Test'";

                // Add same property to imported user file
                mainProj.SetImportedProperty("Prop", "FromUserFile",
                    configCondition1, importedProj, PropertyPosition.UseExistingOrCreateAfterLastImport);

                mainProj.SetImportedProperty("Prop", "FromUserFile",
                    configCondition2, importedProj, PropertyPosition.UseExistingOrCreateAfterLastImport);

                mainProj.SetImportedProperty("Prop", "FromUserFile",
                    configTestCondition, importedProj, PropertyPosition.UseExistingOrCreateAfterLastImport);

                mainProj.RemovePropertyGroupsWithMatchingCondition(configTestCondition, true /* include imported */);
                importedProj.RemovePropertyGroupsWithMatchingCondition(configTestCondition, true /* include imported */);

                string[] configs = mainProj.GetConditionedPropertyValues("Configuration");

                Assertion.AssertEquals(2, configs.Length);
                Assertion.Assert(configs[0] == "Config1" || configs[1] == "Config1");
                Assertion.Assert(configs[0] == "Config2" || configs[1] == "Config2");
            }
            finally
            {
                File.Delete(mainProjFilename);
                File.Delete(importedProjFilename);
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:56,代码来源:Project_Tests.cs

示例4: RemovePropertyGroupsWithMatchingConditionMatchInImported_True

 public void RemovePropertyGroupsWithMatchingConditionMatchInImported_True()
 {
     string importedProjFilename = String.Empty;
     string mainProjFilename = String.Empty;
     try
     {
         importedProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(TestData.PropertyGroup);
         mainProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(TestData.Content3SimpleTargetsDefaultSpecified);
         Project mainProject = new Project(new Engine());
         Project importedProject = new Project(mainProject.ParentEngine);
         mainProject.Load(mainProjFilename);
         importedProject.Load(importedProjFilename);
         BuildPropertyGroup referenceGroup = mainProject.AddNewPropertyGroup(true);
         referenceGroup.Condition = "true";
         mainProject.SetImportedProperty("newp", "newv", "true", importedProject);
         Assertion.AssertEquals(2, mainProject.PropertyGroups.Count);
         mainProject.RemovePropertyGroupsWithMatchingCondition("true", true);
         Assertion.AssertEquals(0, mainProject.PropertyGroups.Count);
     }
     finally
     {
         CompatibilityTestHelpers.RemoveFile(importedProjFilename);
         CompatibilityTestHelpers.RemoveFile(mainProjFilename);
     }
 }
开发者ID:nikson,项目名称:msbuild,代码行数:25,代码来源:Project_Tests.cs


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