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


C# ProjectInstance.ToProjectItem方法代码示例

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


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

示例1: GetProjects

        public IEnumerable<VSProject> GetProjects()
        {
            List<string> projFilePaths = ExtractProjects(pathToSolutionFile);
              var projectItems = new ConcurrentBag<VSProject>();

              // let's do sequential for now
              //foreach (var pf in projFilePaths)
              Parallel.ForEach(projFilePaths, pf =>
              {
            if (File.Exists(pf))
            {
              IDictionary<string, string> props = new Dictionary<string, string>();
              props.Add("Configuration", "Debug");
              props.Add("Platform", "x64");
              var projInst = new ProjectInstance(pf, props, "4.0");
              var pi = projInst.ToProjectItem();
              projectItems.Add(pi);
            }
              });

              return projectItems;
        }
开发者ID:nesteruk,项目名称:BigCity,代码行数:22,代码来源:Solution.cs

示例2: GetProjectReferences

        public static List<ProjectCreator.ProjectReference> GetProjectReferences(this ProjectInstance p)
        {
            var references = new List<ProjectCreator.ProjectReference>();
              foreach (var i in p.Items)
              {
            if (i.ItemType.Equals("ProjectReference"))
            {
              var proj = i.Metadata.SingleOrDefault(z => z.Name.Equals("Project"));
              if (proj != null)
              {
            references.Add(new ProjectCreator.ProjectReference{
              Id=Guid.Parse(proj.EvaluatedValue),
              FileName = i.EvaluatedInclude
            });
              }
              else
              {
            var include = i.EvaluatedInclude;
            // try to get physical file and projectguid from that
            string dir = Path.GetDirectoryName(p.FullPath);
            string projPath = Path.GetFullPath(Path.Combine(dir, include));
            if (File.Exists(projPath))
            {
              var pi = new ProjectInstance(projPath);
              var item = pi.ToProjectItem();
              references.Add(new ProjectCreator.ProjectReference {Id = item.ProjectGuid, FileName = projPath});
            }
            else
            {
              // hack: just don't reference this
              //throw new Exception("Project " + p.FullPath + " references non-existent project " + projPath);
            }
              }
            }
              }

              return references;
        }
开发者ID:nesteruk,项目名称:BigCity,代码行数:38,代码来源:ProjectItemExtensions.cs


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