Example #1
0
        private ProjectFileBase OpenProject(string filename, bool recurse)
        {
            ProjectFileBase project = null;

            if (filename.EndsWith(".wixproj"))
            {
                project = OpenWixProject(filename);
            }
            else if (filename.EndsWith(".csproj"))
            {
                project = OpenVisualStudioCsProject(filename);
            }
            else if (filename.EndsWith(".vcxproj"))
            {
                project = OpenVisualStudioVCxProject(filename);
            }
            else if (filename.EndsWith(".proj"))
            {
                project = OpenMsBuildProject(filename);
            }
            else if (filename.EndsWith(".sln"))
            {
                project = VisualStudioSolution = OpenVisualStudioSolution(filename);
            }

            else
            {
                base.HandleException(this, new Exception($"Un-registered file extension {System.IO.Path.GetExtension(filename)}"));
            }

            if (project != null)
            {
                Terminal.WriteLine($"{project.FileType} opened: {project.ProjectPath}");
                Terminal.Write(project.Results(Verbose));
                if (project.ImportFailed)
                {
                    FileOpenFailed(project.FileType, filename);
                }

                MissingProjects.AddRange(project.MissingProjects);
                MissingFiles.AddRange(project.MissingFiles);
                if (recurse)
                {
                    foreach (var nested in project.Projects)
                    {
                        OpenProject(nested.Path, recurse);
                    }
                }
            }
            else
            {
                HandleException(this, new Exception($"File open failed! [{filename}]"));
            }
            return(project);
        }
 protected override void Analyze(string fileName, ExceptionHandler exceptionHandler)
 {
     MissingFiles.AddRange(
         SourceFiles.Where(
             source => (!source.FileExists && (source.ResourceType != ResourceType.Reference))));
 }