Esempio n. 1
0
        public List <MSBProject> GetProjects(bool useGlobalProps = true)
        {
            if (msprojectCollection == null)
            {
                msprojectCollection = ProjectCollection.GlobalProjectCollection;
            }
            msprojectCollection.UnloadAllProjects();

            var csfileList = Directory.EnumerateFiles(inputDir, "*.csproj", SearchOption.AllDirectories).AsParallel();
            var vcfileList = Directory.EnumerateFiles(inputDir, "*.vcxproj", SearchOption.AllDirectories).AsParallel();
            var fileList   = csfileList.Concat(vcfileList);

            CountFoundFiles = fileList.Count();
            ConcurrentBag <MSBProject> bag = new ConcurrentBag <MSBProject>();

            Parallel.ForEach(fileList, (file) =>
            {
                try
                {
                    MSBProject p = null;
                    if (useGlobalProps)
                    {
                        p = new MSBProject(file, _globalProperties, toolsVersion);
                    }
                    else
                    {
                        p = new MSBProject(file, toolsVersion);
                    }

                    bag.Add(p);
                    msprojectCollection.LoadProject(p.FullPath);
                }
                catch (Exception e)
                {
                    Utils.WL(ConsoleColor.Red, String.Format("Bad File: {0}", file));
                    Utils.WL(ConsoleColor.DarkGray, e.Message);
                }
            });

            var sorted = from proj in bag
                         orderby proj.FullPath
                         select proj;

            return(sorted.ToList());
        }
Esempio n. 2
0
 private void GetPropertiesFor(MSBProject project)
 {
     foreach (ProjectProperty prop in project.AllEvaluatedProperties)
     {
         if (!prop.IsImported && !prop.IsEnvironmentProperty && !prop.IsReservedProperty)
         {
             string key = prop.Name;
             if (_allFoundProperties.ContainsKey(key))
             {
                 _allFoundProperties[key].Add(project);
             }
             else
             {
                 _allFoundProperties[key] = new ReferencedProperty(prop, project)
                 {
                     UsedCount = 1
                 };
             }
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="prop">A property instance from the project</param>
 public ReferencedProperty(ProjectProperty prop, MSBProject proj)
 {
     this.Name = prop.Name;
     _projects.Add(proj);
 }
Esempio n. 4
0
 public void AddProject(MSBProject p)
 {
     Count++;
     _projects.Add(p);
 }
Esempio n. 5
0
 public ReferencedValues(MSBProject proj)
 {
     _projects.Add(proj);
     Count++;
 }
Esempio n. 6
0
 public void Add(MSBProject proj)
 {
     _projects.Add(proj);
     UsedCount++;
 }