Beispiel #1
0
 static void ThereMustBeAProject(Solution solution, List<SolutionValidationFailureReason> failures)
 {
     if (!solution.Projects.Any())
     {
         failures.Add(new SolutionValidationFailureReason(SolutionValidationFailureReasons.NoProjects, "No projects could be found.  Remember to add a Project.nosln file"));
     }
 }
Beispiel #2
0
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            foreach (var reference in codeDirectory.References)
            {
                var project = solution.GetProject(codeDirectory.Project.AssemblyName);
                var referencedProject = solution.FindProject(reference.Name);
                if (referencedProject != null)
                {
                    project.AddReference(new ProjectReference
                    {
                        Project = referencedProject, 
                        RelativePathToProject = relativePathGenerator.GeneratePath(project.Path, referencedProject.GeneratedProjectFilePath)
                    });
                }
                else
                {
                    var assemblyReference = new AssemblyReference {Name = reference.Name, HintPath = reference.HintPath};

                    assemblyReference.HintPath = assemblyReference.HintPath;

                    project.AddReference(assemblyReference);
                }
            }

            codeDirectory.Directories.Each(x => Execute(solution, x));
        }
Beispiel #3
0
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var failures = new List<SolutionValidationFailureReason>();
            
            ThereMustBeAProject(solution, failures);
            EachProjectMustHaveATemplate(solution, failures);

            if (failures.Count > 0) throw new SolutionValidationException(failures);
        }
 static void InitDirectory()
 {
     Solution = new Solution();
     CodeDirectory = TestEntityFactory.CreateCodeDirectory("test");
     var tempaltes = TestEntityFactory.CreateCodeDirectory("_templates");
     tempaltes.AddFile(new TestFile("Test") {Contents = "<root />"});
     CodeDirectory.AddCodeDirectory(tempaltes);
     Solution.AddProject(new Project {AssemblyName = "Test", Name = "Test"});
 }
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var fileTypeHierarchy = fileTypeHierarchyBuilder.Generate(codeDirectory);

            foreach (var file in solution.Projects.SelectMany(x => x.Files))
            {
                SetFileType(file, fileTypeHierarchy);
            }
        }
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            if (!string.IsNullOrEmpty(codeDirectory.ProjectTemplate))
            {
                var project = solution.GetProject(codeDirectory.Project.AssemblyName);
                project.ProjectTemplate = CreateTemplate(codeDirectory.ProjectTemplate);
            }

            codeDirectory.Directories.Each(x => Execute(solution, x));
        }
        void AddFiles(Solution solution, CodeDirectory currentDirectory, IFileInclusionHierarchy fileInclusionHierarchy = null, Project currentProject = null)
        {
            fileInclusionHierarchy = UpdateFileInclusionPolicy(currentDirectory, fileInclusionHierarchy);
            if (currentDirectory.Project != null)
            {
                currentProject = solution.GetProject(currentDirectory.Project.AssemblyName);
            }

            AddIncludedFiles(currentDirectory, fileInclusionHierarchy, currentProject);

            currentDirectory.Directories.Each(x => AddFiles(solution, x, fileInclusionHierarchy, currentProject));
        }
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var libDirectory = codeDirectory.Directories.FirstOrDefault(x => x.Name.Equals("LIB", StringComparison.InvariantCultureIgnoreCase));

            if (libDirectory == null)
                return;

            var references = solution.Projects.SelectMany(x => x.AssemblyReferences.Where(y => string.IsNullOrEmpty(y.HintPath)));

            foreach (var assemblyReference in references)
            {
                assemblyReference.HintPath = FindFile(libDirectory, assemblyReference.Name);
            }
        }
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Microsoft Visual Studio Solution File, Format Version 11.00");
            solution.Projects.Each(
                x => stringBuilder.AppendFormat("Project(\"{0:B}\") = \"{1}\", \"{2}\", \"{3:B}\"{4}EndProject{4}",
                                                x.ProjectTypeGuid, 
                                                x.Name, 
                                                relativePathGenerator.GeneratePath(solution.SolutionPath, x.GeneratedProjectFilePath), 
                                                x.Guid, 
                                                Environment.NewLine));

            fileSystem.WriteFile(Path.Combine(solution.SolutionPath, "All.sln"), stringBuilder.ToString());
        }
 public void Execute(Solution solution, CodeDirectory codeDirectory)
 {
     var templateFolder = codeDirectory.Directories.FirstOrDefault(x => x.Name.Equals("_templates", StringComparison.InvariantCultureIgnoreCase));
     if (templateFolder == null) return;
     foreach (var project in solution.Projects.Where(x => x.ProjectTemplate == null))
     {
         var projectType = projectTypeNamingConvention.GetProjectType(project.Name);
         var xml = templateFolder.Files.FirstOrDefault(f => f.FileName.StartsWith(projectType.Name, StringComparison.InvariantCultureIgnoreCase));
         if (xml == null)
         {
             continue;
         }
         project.ProjectTemplate = new ProjectTemplate { Xml = XDocument.Parse(xml.Contents) };
     }
 }
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            if (codeDirectory.Project != null)
            {
                solution.AddProject(new Project
                {
                    Name = codeDirectory.Project.Name,
                    Path = codeDirectory.Path,
                    Guid = codeDirectory.Project.Guid,
                    Namespace = codeDirectory.Project.Namespace,
                    OutputType = codeDirectory.Project.OutputType,
                    AssemblyName = codeDirectory.Project.AssemblyName,
                    Extension = codeDirectory.Project.Extension,
                    GeneratedProjectFilePath = Path.Combine(codeDirectory.Path, codeDirectory.Project.Name + codeDirectory.Project.Extension),
                    ProjectTypeGuid = codeDirectory.Project.ProjectTypeGuid
                });
            }

            codeDirectory.Directories.Each(x => Execute(solution, x));
        }
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var sourceDirectory = codeDirectory.Directories.FirstOrDefault(x => IsSourceDirectory(x.Name));
            if (sourceDirectory == null) return;

            foreach (var projectFolder in sourceDirectory.Directories)
            {
                if (projectFolder.Files.Any(x => x.FileName.Equals(ParserRegistry.ProjectFileName, StringComparison.InvariantCultureIgnoreCase)))
                    continue;
                var projectType = projectTypeNamingConvention.GetProjectType(projectFolder.Name);
                projectFolder.Project = (new ProjectInfo
                {
                    AssemblyName = projectFolder.Name,
                    Name = projectFolder.Name,
                    Namespace = projectFolder.Name,
                    OutputType = projectType.OutputType,
                    Guid = guidGenerator.Generate(),
                    Extension = ".csproj",
                    ProjectTypeGuid = projectType.ProjectTypeGuid,
                });
            }
        }
Beispiel #13
0
 void EachProjectMustHaveATemplate(Solution solution, List<SolutionValidationFailureReason> failures)
 {
     solution.Projects.Where(x => x.ProjectTemplate == null).Each(x => failures.Add(
         new SolutionValidationFailureReason(SolutionValidationFailureReasons.MissingProjectTemplate,
                                             string.Format("The project {0} is missing a template", (object) x.Name))));
 }
Beispiel #14
0
 public void Execute(CodeDirectory solutionCodeDirectory)
 {
     var solution = new Solution { SolutionPath = solutionCodeDirectory.Path };
     var steps = stepsBuilder.BuildSteps();
     steps.Each(x => x.Execute(solution, solutionCodeDirectory));
 }
 public void Execute(Solution solution, CodeDirectory codeDirectory)
 {
     AddFiles(solution, codeDirectory);
 }
 public void Execute(Solution solution, CodeDirectory codeDirectory)
 {
     solution.Projects.Each(FixReferencesForProject);
 }