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


C# ProjectInstance.GetItems方法代码示例

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


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

示例1: GetTargetFrameworkSubsets

            private static string[] GetTargetFrameworkSubsets(ProjectInstance projectInstance)
            {
                IEnumerable<ITaskItem> taskItems = projectInstance.GetItems(ReferenceInstalledAssemblySubsets);

                string[] targetFrameworkSubsets = (taskItems.Select((Func<ITaskItem, string>)((item) => { return item.ItemSpec.Trim(); }))).ToArray();

                return targetFrameworkSubsets;
            }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:8,代码来源:DesignTimeAssemblyResolution.cs

示例2: GetItems

        /// <summary>
        /// Get all items of type 'i'
        /// </summary>
        private static IList<ProjectItemInstance> GetItems(string content)
        {
            ProjectRootElement xml = ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
            ProjectInstance project = new ProjectInstance(xml);

            return Helpers.MakeList(project.GetItems("i"));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:10,代码来源:ProjectItemInstance_Tests.cs

示例3: GetInstalledAssemblySubsetTables

 private static ITaskItem[] GetInstalledAssemblySubsetTables(ProjectInstance projectInstance)
 {
     return projectInstance.GetItems(InstalledAssemblySubsetTablesName).ToArray();
 }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:4,代码来源:DesignTimeAssemblyResolution.cs

示例4: GetLatestTargetFrameworkDirectories

            private static string[] GetLatestTargetFrameworkDirectories(ProjectInstance projectInstance)
            {
                IEnumerable<ITaskItem> taskItems = projectInstance.GetItems(LatestTargetFrameworkDirectoriesName);

                string[] latestTargetFrameworkDirectory = (taskItems.Select((Func<ITaskItem, string>)((item) => { return item.ItemSpec.Trim(); }))).ToArray();

                return latestTargetFrameworkDirectory;
            }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:8,代码来源:DesignTimeAssemblyResolution.cs

示例5: GetCandidateAssemblyFiles

            private static string[] GetCandidateAssemblyFiles(ProjectInstance projectInstance)
            {
                var candidateAssemblyFilesList = new List<ProjectItemInstance>();

                candidateAssemblyFilesList.AddRange(projectInstance.GetItems(Content));
                candidateAssemblyFilesList.AddRange(projectInstance.GetItems(None));
                candidateAssemblyFilesList.AddRange(projectInstance.GetItems(RARResolvedReferencePath));

                string[] candidateAssemblyFiles = candidateAssemblyFilesList.Select((Func<ProjectItemInstance, string>)((item) => { return item.GetMetadataValue("FullPath").Trim(); })).ToArray();

                return candidateAssemblyFiles;
            }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:12,代码来源:DesignTimeAssemblyResolution.cs

示例6: GetFullFrameworkAssemblyTables

 private static ITaskItem[] GetFullFrameworkAssemblyTables(ProjectInstance projectInstance)
 {
     return projectInstance.GetItems(FullFrameworkAssemblyTablesName).ToArray();
 }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:4,代码来源:DesignTimeAssemblyResolution.cs

示例7: TransformsUseCorrectDirectory_Basic_NotSaved

        public void TransformsUseCorrectDirectory_Basic_NotSaved()
        {
            string projectFileContent = ObjectModelHelpers.CleanupFileContents(@"
                    <Project xmlns='msbuildnamespace'>
                        <ItemGroup>
                            <IntermediateAssembly Include='obj\i386\foo.dll'/>
                            <BuiltProjectOutputGroupKeyOutput Include=""@(IntermediateAssembly->'%(FullPath)')""/>
                        </ItemGroup>
                    </Project>");

            ProjectRootElement xml = ProjectRootElement.Create(XmlReader.Create(new StringReader(projectFileContent)));

            Project project = new Project(xml);
            ProjectInstance projectInstance = new ProjectInstance(xml);

            Assert.Equal(Path.Combine(Environment.CurrentDirectory, @"obj\i386\foo.dll"), project.GetItems("BuiltProjectOutputGroupKeyOutput").First().EvaluatedInclude);
            Assert.Equal(Path.Combine(Environment.CurrentDirectory, @"obj\i386\foo.dll"), projectInstance.GetItems("BuiltProjectOutputGroupKeyOutput").First().EvaluatedInclude);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:18,代码来源:Project_Tests.cs

示例8: TransformsUseCorrectDirectory_DirectoryNameItemFunction

        public void TransformsUseCorrectDirectory_DirectoryNameItemFunction()
        {
            string file = null;

            string projectFileContent = ObjectModelHelpers.CleanupFileContents(@"
                    <Project xmlns='msbuildnamespace'>
                        <ItemGroup>
                            <IntermediateAssembly Include='obj\i386\foo.dll'/>
                            <BuiltProjectOutputGroupKeyOutput Include=""@(IntermediateAssembly->DirectoryName())""/>
                        </ItemGroup>
                    </Project>");

            ProjectRootElement xml = ProjectRootElement.Create(XmlReader.Create(new StringReader(projectFileContent)));

            try
            {
                file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
                xml.FullPath = file;

                Project project = new Project(xml);
                ProjectInstance projectInstance = new ProjectInstance(xml);

                // Should be the full path to the directory
                Assert.Equal(Path.Combine(Path.GetTempPath() /* remove c:\ */, @"obj\i386"), project.GetItems("BuiltProjectOutputGroupKeyOutput").First().EvaluatedInclude);
                Assert.Equal(Path.Combine(Path.GetTempPath() /* remove c:\ */, @"obj\i386"), projectInstance.GetItems("BuiltProjectOutputGroupKeyOutput").First().EvaluatedInclude);
            }
            finally
            {
                File.Delete(file);
            }
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:31,代码来源:Project_Tests.cs

示例9: AssertProjectContainsItem

        /// <summary>
        /// Checks the provided project for a matching itemtype and include value.  If it
        /// does not exist, asserts. 
        /// </summary>
        private void AssertProjectContainsItem(ProjectInstance msbuildProject, string itemType, string include)
        {
            IEnumerable<ProjectItemInstance> itemGroup = msbuildProject.GetItems(itemType);
            Assert.IsNotNull(itemGroup);

            foreach (ProjectItemInstance item in itemGroup)
            {
                if (item.ItemType == itemType && item.EvaluatedInclude == include)
                {
                    return;
                }
            }

            Assert.IsTrue(false);
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:19,代码来源:SolutionProjectGenerator_Tests.cs

示例10: AssertProjectItemNameCount

 /// <summary>
 /// Counts the number of items with a particular itemtype in the provided project, and 
 /// asserts if it doesn't match the provided count.
 /// </summary>
 private void AssertProjectItemNameCount(ProjectInstance msbuildProject, string itemType, int count)
 {
     IEnumerable<ProjectItemInstance> itemGroup = msbuildProject.GetItems(itemType);
     Assert.IsNotNull(itemGroup);
     Assert.AreEqual(count, itemGroup.Count());
 }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:10,代码来源:SolutionProjectGenerator_Tests.cs

示例11: getDependentProjectGuids

		static Guid[] getDependentProjectGuids(ProjectInstance instance)
		{
			var refs = instance.GetItems("ProjectReference").Select(item => Guid.Parse(item.GetMetadataValue("Project"))).ToArray();
			return refs;
		}
开发者ID:pragmatrix,项目名称:BuildOnSave,代码行数:5,代码来源:BackgroundBuild2.cs

示例12: PhoenixBatchingIssue

        public void PhoenixBatchingIssue()
        {
            ProjectRootElement xml = ProjectRootElement.Create(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(@"
            <Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                <ItemGroup>
                    <CppCompile Include='gen.cpp'/>
                    <CppCompile Include='def.cpp'>
                        <ObjectFile>def.obj</ObjectFile>
                    </CppCompile>
                </ItemGroup>
                
                <Target Name='t'>
                    <ItemGroup>
                        <CppCompile>
                            <IncludeInLib Condition=""'%(CppCompile.IncludeInLib)' == ''"">true</IncludeInLib>
                        </CppCompile>
                        <CppCompile>
                            <ObjectFile>%(Filename).obj</ObjectFile>
                        </CppCompile>
                    </ItemGroup>
                </Target>
            </Project>
            "))));
            ProjectInstance instance = new ProjectInstance(xml);
            instance.Build();

            Assert.AreEqual(2, instance.Items.Count());
            Assert.AreEqual("gen.obj", instance.GetItems("CppCompile").First().GetMetadataValue("ObjectFile"));
            Assert.AreEqual("def.obj", instance.GetItems("CppCompile").Last().GetMetadataValue("ObjectFile"));
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:30,代码来源:IntrinsicTask_Tests.cs

示例13: ExpandPropertyThenTrim

		public void ExpandPropertyThenTrim ()
		{
			string test = @"A
B
C
    ";
			string project_xml = string.Format (@"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
  <PropertyGroup>
    <Test>{0}</Test>
    <Test2>$(TEST)</Test2>
  </PropertyGroup>
  <ItemGroup>
    <X Include='$(TEST)' />
    <X2 Include='$(TEST)z' />
  </ItemGroup>
</Project>", test);
			var xml = XmlReader.Create (new StringReader (project_xml));
			var root = ProjectRootElement.Create (xml);
			root.FullPath = "ProjectItemTest.ExpandPropertyThenTrim.proj";
			var proj = new ProjectInstance (root);
			Assert.AreEqual (test, proj.GetPropertyValue ("TEST"), "#1");
			Assert.AreEqual (test, proj.GetPropertyValue ("TEST2"), "#2");
			Assert.AreEqual (test.Trim (), proj.GetItems ("X").First ().EvaluatedInclude, "#3");			
			Assert.AreEqual (test + "z", proj.GetItems ("X2").First ().EvaluatedInclude, "#4");
		}
开发者ID:xzkmxd,项目名称:mono,代码行数:25,代码来源:ProjectItemTest.cs

示例14: ItemsInTargets

		[Category ("NotWorking")] // until we figure out why it fails on wrench.
		public void ItemsInTargets ()
		{
			string project_xml = @"<Project DefaultTargets='Default' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
	<Target Name='Default'>
		<PropertyGroup>
			<_ExplicitMSCorlibPath>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries ('$(TargetFrameworkIdentifier)', '$(TargetFrameworkVersion)', '$(TargetFrameworkProfile)'))\mscorlib.dll</_ExplicitMSCorlibPath>
		</PropertyGroup>
		<ItemGroup>
			<_ExplicitReference
				Include='$(_ExplicitMSCorlibPath)'
				Condition='Exists($(_ExplicitMSCorlibPath))'>
				<Private>false</Private>
			</_ExplicitReference>
		</ItemGroup>
	</Target>
	<Import Project='$(MSBuildBinPath)\\Microsoft.CSharp.targets' />
</Project>";
			var xml = XmlReader.Create (new StringReader (project_xml));
			var root = ProjectRootElement.Create (xml);
			root.FullPath = "ProjectInstanceTest.ConditionalExpression.proj";
			var proj = new ProjectInstance (root, null, "4.0", ProjectCollection.GlobalProjectCollection);
			proj.Build ();
			// make sure the property value expansion is done successfully.
			Assert.IsTrue (!string.IsNullOrEmpty (proj.GetPropertyValue ("_ExplicitMSCorlibPath")), "premise: propertyValue by ToolLocationHelper func call");
			var items = proj.GetItems ("_ExplicitReference");
			// make sure items are stored after build.
			Assert.IsTrue (items.Any (), "items.Any");
			Assert.IsTrue (!string.IsNullOrEmpty (items.First ().EvaluatedInclude), "item.EvaluatedInclude");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:30,代码来源:ProjectInstanceTest.cs

示例15: BuildCommonResolveAssemblyReferences

		public void BuildCommonResolveAssemblyReferences ()
		{
			string project_xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
  <Import Project='$(MSBuildToolsPath)\Microsoft.Common.targets' />
  <ItemGroup>
    <Reference Include='System.Core' />
    <Reference Include='System.Xml' />
  </ItemGroup>
</Project>";
			var xml = XmlReader.Create (new StringReader (project_xml));
			var root = ProjectRootElement.Create (xml);
			root.FullPath = "BuildManagerTest.BuildCommonResolveAssemblyReferences.proj";
			var proj = new ProjectInstance (root);
			var manager = new BuildManager ();
			var parameters = new BuildParameters () { Loggers = new ILogger [] {new ConsoleLogger (LoggerVerbosity.Diagnostic)} };
			var request = new BuildRequestData (proj, new string [] {"ResolveAssemblyReferences"});
			Assert.AreEqual (string.Empty, proj.GetPropertyValue ("TargetFrameworkDirectory"), "#1-1");
			var result = manager.Build (parameters, request);
			Assert.AreNotEqual (string.Empty, proj.GetPropertyValue ("TargetFrameworkDirectory"), "#1-2"); // filled during build.
			Assert.IsTrue (result.ResultsByTarget.ContainsKey ("GetFrameworkPaths"), "#2-1");
			Assert.IsTrue (result.ResultsByTarget.ContainsKey ("PrepareForBuild"), "#2-2");
			Assert.IsTrue (result.ResultsByTarget.ContainsKey ("ResolveAssemblyReferences"), "#2-3");
			var items = proj.GetItems ("ReferencePath");
			Assert.AreEqual (2, items.Count (), "#3");
			var syscore = items.FirstOrDefault (i => Path.GetFileName (i.EvaluatedInclude) == "System.Core.dll");
			var sysxml = items.FirstOrDefault (i => Path.GetFileName (i.EvaluatedInclude) == "System.Xml.dll");
			Assert.IsNotNull (syscore, "#4-1");
			Assert.IsNotNull (sysxml, "#4-2");
			Assert.IsTrue (File.Exists (syscore.EvaluatedInclude), "#5-1");
			Assert.IsTrue (File.Exists (sysxml.EvaluatedInclude), "#5-1");
			Assert.AreEqual (BuildResultCode.Success, result.OverallResult, "#6");
		}
开发者ID:GirlD,项目名称:mono,代码行数:32,代码来源:BuildManagerTest.cs


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