예제 #1
0
        public static ProjectFileBase Open(string filename, ExceptionHandler exceptionHandler)
        {
            ProjectFileBase project = null;

            if (filename.EndsWith(".wixproj"))
            {
                project = Wix.WixProject.Deserialize(filename, exceptionHandler);
            }
            else if (filename.EndsWith(".csproj"))
            {
                project = VisualStudio.CsProj.VisualStudioCsProject.Deserialize(filename, exceptionHandler);
            }
            else if (filename.EndsWith(".vcxproj"))
            {
                project = VisualStudio.VCxProj.VisualStudioVCxProject.Deserialize(filename, exceptionHandler);
            }
            else if (filename.EndsWith(".proj"))
            {
                project = VisualStudio.MsBuild.MsBuildProject.Deserialize(filename, exceptionHandler);
            }
            else if (filename.EndsWith(".sln"))
            {
                project = VisualStudio.sln.VisualStudioSolution.Deserialize(filename, exceptionHandler);
            }
            else
            {
                exceptionHandler.Invoke(nameof(ProjectFile), new Exception($"Un-registered file extension {System.IO.Path.GetExtension(filename)}"));
            }

            return(project);
        }
예제 #2
0
 public ProjectFile(string fileName, ResourceType resourceType, ProjectFileBase project)
 {
     FileName = fileName;
     Path     = project.GetFullPath(FileName);
     //Path = System.IO.Path.GetFullPath(System.IO.Path.Combine(projectPath, FileName));
     ResourceType = resourceType;
 }
예제 #3
0
 public NestedProject(ProjectFileBase project, ProjectItemGroupProjectReference reference)
 {
     Name    = reference.Name;
     Include = reference.Include;
     Project = reference.Project;
     Path    = project.GetFullPath(Include);
     //Path = System.IO.Path.GetFullPath(System.IO.Path.Combine(projectPath, Include));
 }
예제 #4
0
        public virtual IEnumerable <string> Compare(ProjectFileBase project, bool verbose)
        {
            var result = new List <string>
            {
                $"Compare Projects",
                $"{this.FileType}:\t{ProjectFilename}",
                $"{project.FileType}:\t{project.ProjectFilename}"
            };

            var missing = this.Projects.Where(nested => project.FindProject(nested.Path) == null).ToList();

            result.Add($"Missing {missing.Count} projects");
            result.AddRange(missing.Select(nested => $"{nested.Path}"));

            return(result);
        }
예제 #5
0
 public static ProjectFile CreateIfValid(ProjectItemGroup item, ResourceType resourceType, ProjectFileBase project)
 {
     return(!string.IsNullOrWhiteSpace(item?.Include) ?
            new ProjectFile(item.Include, resourceType, project)
     {
         Dependancy = (item as Compile)?.DependentUpon
     } :
            null);
 }
예제 #6
0
 public NestedProject(ProjectFileBase project, string item)
 {
     Name = item;
     Path = project.GetFullPath(item);
     //Path = System.IO.Path.GetFullPath(System.IO.Path.Combine(projectPath,item));
 }
예제 #7
0
 /// <summary>
 /// Merges the specified project into the current project.
 /// </summary>
 /// <param name="project">The project whose contents are to be merged into the current project.</param>
 /// <param name="verbose">if set to <c>true</c> [verbose].</param>
 /// <returns>IEnumerable&lt;System.String&gt;.</returns>
 /// <exception cref="NotImplementedException"></exception>
 public virtual IEnumerable <string> Merge(ProjectFileBase project, IEnumerable <string> omit, bool verbose)
 {
     throw new NotImplementedException($"{GetType().Name}.{nameof(Merge)} not implemented!");
 }
예제 #8
0
        public static IList <string> ExecuteCommandLine()
        {
            if (CommandLineArguments?.Count > 0)
            {
                Debug.Assert(Verbose == CommandLineArguments.Keys.Contains("-verbose"));
                Debug.Assert(Headless == CommandLineArguments.Keys.Contains("-headless"));
                string          logPath  = null;
                ProjectFileBase project1 = null;
                ProjectFileBase project2 = null;

                List <string> results = new List <string>();
                try
                {
                    if (Verbose)
                    {
                        CommandLineArguments.ForEach((arg) => results.Add($"{arg.Key} {arg.Value}"));
                    }
                    List <string> omit = CommandLineArguments.ContainsKey("-omit") ?
                                         CommandLineArguments["-omit"].Split(',').Select((o) => (o.Trim(' '))).ToList <string>()
                        : null;

                    foreach (var arg in CommandLineArguments)
                    {
                        string validPath = null;
                        if (Verbose)
                        {
                            results.Add(null);
                            results.Add($"{arg.Key} : {arg.Value}");
                        }

                        switch (arg.Key)
                        {
                        case "-verbose": break;     // Verbose already handled

                        case "-headless": break;    // Headless already handled

                        case "-log":
                            logPath = arg.Value;
                            break;

                        case "-open":
                            validPath = VerifyAndGetPath(arg.Value);
                            project1  = Commands.Open(validPath, null);
                            if (project1 == null)
                            {
                                throw new Exception($"Error processing argument {arg.Key} {arg.Value}");
                            }
                            results.AddRange(project1.Results(Verbose));
                            break;

                        case "-save":
                            project1.Serialize(arg.Value, null);
                            results.AddRange(project1.Results(Verbose));
                            break;

                        case "-compare":
                            validPath = VerifyAndGetPath(arg.Value);
                            project2  = Commands.Open(validPath, null);
                            if (project2 == null)
                            {
                                throw new Exception($"Error processing argument {arg.Key} {arg.Value}");
                            }
                            results.AddRange(project1.Compare(project2, Verbose));
                            break;

                        case "-merge":
                            validPath = VerifyAndGetPath(arg.Value);
                            project2  = Commands.Open(validPath, null);
                            if (project2 == null)
                            {
                                throw new Exception($"Error processing argument {arg.Key} {arg.Value}");
                            }

                            results.AddRange(project1.Merge(project2, omit, Verbose));
                            break;
                        }
                    }
                }
                catch (Exception exc)
                {
                    results.Add($"{exc.GetType()} {exc.Message}");
                }
                if (!string.IsNullOrEmpty(logPath))
                {
                    File.WriteAllLines(logPath, results);
#if DEBUG
                    System.Diagnostics.Process.Start(logPath);
#endif
                }
                return(results);
            }
            return(null);
        }