예제 #1
0
 public ProjectInfo(SolutionInfo solutionInfo, FilePath path, SolutionProject solutionProject, ProjectParserResult parserResult)
 {
     this.SolutionInfo    = solutionInfo;
     this.Path            = path;
     this.SolutionProject = solutionProject;
     this.ParserResult    = parserResult;
 }
예제 #2
0
        private SolutionProject GetSolutionProjectEntryFrom(Project project, SolutionFileInfo solutionFileInfo)
        {
            SolutionProject toReturn = new SolutionProject(project.Guid, project.TypeGuid, project.Name, project.RelativePath, project.Sections, project.Dependencies);

            SetAdditionalProjectProperties(toReturn, project.Guid, solutionFileInfo, config =>
            {
                if (!toReturn.ConfigurationPlatformMapping.TryGetValue(config.SolutionConfig, out ProjectConfigurationPlatformMapping mapping))
                {
                    toReturn.ConfigurationPlatformMapping.Add(config.SolutionConfig, mapping = new ProjectConfigurationPlatformMapping());
                }
                mapping.ConfigurationPlatform = config.ProjectConfig;

                switch (config.Property)
                {
                case "ActiveCfg":
                    break;

                case "Build.0":
                    mapping.EnabledForBuild = true;
                    break;
                }
            });

            return(toReturn);
        }
        private void GetTaskDatabaseForProject(SolutionProject solutionProject)
        {
            var fi             = new FileInfo(solutionProject.FilePath);
            var nulahTaskFiles = fi.Directory.EnumerateFiles()
                                 .FirstOrDefault(x => x.Extension == $".{NULAH_DB_EXTENSION}");

            if (nulahTaskFiles == null)
            {
                return;
            }

            if (_sqliteProvider.DataSourceExists(nulahTaskFiles.Name) == false)
            {
                var extensionlessFileName = Path.GetFileNameWithoutExtension(nulahTaskFiles.Name);
                _sqliteProvider.CreateOrRegisterDataSource(extensionlessFileName, nulahTaskFiles.FullName);
                var dbSchema = _sqliteProvider.Query <NulahDBMeta>(extensionlessFileName, $"SELECT * FROM [{nameof(NulahDBMeta)}] LIMIT 1");

                if (dbSchema.FirstOrDefault() != null)
                {
                    solutionProject.Database = dbSchema.First();
                }
                else
                {
                    // In the unlikely event that the task database isn't valid, unregister it
                    _sqliteProvider.UnregisterDatasource(nulahTaskFiles.Name);
                }
            }
        }
예제 #4
0
        private TreeNode CreateProjectNode(TreeNode root, SolutionProject project)
        {
            if (this.projectNodes.ContainsKey(project))
            {
                return(projectNodes[project]);
            }

            var parent = root;

            if (project.ParentProject != null)
            {
                parent = CreateProjectNode(root, project.ParentProject);
            }

            var node = new TreeNode(project.Name);

            node.Tag = project;
            var projectType = project.IsFolder ? ProjectType.SolutionFolder : ProjectTypes.Find(project.ProjectTypeId);

            node.ImageKey         = ProjectIcons[projectType];
            node.SelectedImageKey = node.ImageKey;
            parent.Nodes.Add(node);
            this.projectNodes.Add(project, node);
            return(node);
        }
        public void SetUp()
        {
            new FileSystem().CreateDirectory("Solution1");
            new FileSystem().CleanDirectory("Solution1");

            theSolutionProject = new SolutionProject("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"FubuMVC.SlickGrid\", \"FubuMVC.SlickGrid\\FubuMVC.SlickGrid.csproj\", \"{A67A0CE1-E4C2-45FC-9019-829D434B2CC4}\"", "Solution1");
        }
        public List <object> slnLines;       // List of either String (line format is not intresting to us), or SolutionProject.
        /// <summary>
        /// Loads visual studio .sln solution
        /// </summary>
        /// <param name="solutionFileName"></param>
        /// <exception cref="System.IO.FileNotFoundException">The file specified in path was not found.</exception>
        public Solution(string solutionFileName)
        {
            slnLines = new List <object>();
            String slnTxt = File.ReadAllText(solutionFileName);

            string[] lines = slnTxt.Split('\n');
            //Match string like: Project("{66666666-7777-8888-9999-AAAAAAAAAAAA}") = "ProjectName", "projectpath.csproj", "{11111111-2222-3333-4444-555555555555}"
            Regex projMatcher = new Regex("Project\\(\"(?<ParentProjectGuid>{[A-F0-9-]+})\"\\) = \"(?<ProjectName>.*?)\", \"(?<RelativePath>.*?)\", \"(?<ProjectGuid>{[A-F0-9-]+})");

            Regex.Replace(slnTxt, "^(.*?)[\n\r]*$", new MatchEvaluator(m =>
            {
                String line = m.Groups[1].Value;
                Match m2    = projMatcher.Match(line);
                if (m2.Groups.Count < 2)
                {
                    slnLines.Add(line);
                    return("");
                }
                SolutionProject s = new SolutionProject();
                foreach (String g in projMatcher.GetGroupNames().Where(x => x != "0"))     /* "0" - RegEx special kind of group */
                {
                    s.GetType().GetField(g).SetValue(s, m2.Groups[g].ToString());
                }
                slnLines.Add(s);
                return("");
            }),
                          RegexOptions.Multiline
                          );
        }
예제 #7
0
        public override SolutionDocumentNode Clone(SolutionDocumentNode newParent)
        {
            var newProj = new SolutionProject(newParent, TypeGuid, Name, Path, Guid);

            newProj.Children.AddRange(Children.Select(x => x.Clone(newProj)));
            return(newProj);
        }
예제 #8
0
        private void ParseProjects(Solution solution, List <string> lines, ref int lineIndex)
        {
            bool more = true;

            while (more && lineIndex < lines.Count)
            {
                string line = lines[lineIndex++];
                if (!line.StartsWith("Project("))
                {
                    more = false;
                }
                else
                {
                    var project = new SolutionProject();
                    int index   = line.IndexOf('{') + 1;
                    project.ProjectTypeId = new Guid(line.Substring(index, line.IndexOf('}', index) - index));
                    index             = line.LastIndexOf('{') + 1;
                    project.ProjectId = new Guid(line.Substring(index, line.IndexOf('}', index) - index));
                    index             = line.IndexOf("= \"") + 3;
                    project.Name      = line.Substring(index, line.IndexOf('\"', index) - index);
                    index             = line.IndexOf(", \"", index) + 3;
                    project.Path      = line.Substring(index, line.IndexOf('\"', index) - index);

                    ParseProjectSections(project, lines, ref lineIndex);

                    solution.Projects.Add(project);
                }

                if (!more)
                {
                    lineIndex--;
                }
            }
        }
예제 #9
0
        public virtual void CollectNestedProjects(Project parentPrj)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            if (string.Compare(parentPrj.Kind, ProjectKinds.vsProjectKindSolutionFolder) != 0)
            {
                return;
            }
            for (var i = 1; i <= parentPrj.ProjectItems.Count; i++)
            {
                Project subProject = parentPrj.ProjectItems.Item(i).SubProject;
                if (subProject == null)
                {
                    continue;
                }

                // If this is another solution folder, do a recursive call, otherwise add
                if (subProject.Kind == ProjectKinds.vsProjectKindSolutionFolder)
                {
                    CollectNestedProjects(subProject);
                }
                else
                {
                    SolutionProject sp = new SolutionProject()
                    {
                        ProjectName       = subProject.Name,
                        ProjectUniqueName = subProject.UniqueName,
                        ProjectRef        = subProject
                    };
                    ComboItemsSourceProjects.Add(sp);
                }
            }
        }
예제 #10
0
 public void CollectProjects()
 {
     Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
     if (Dte == null)
     {
         return;
     }
     foreach (Project p in Dte.Solution.Projects)
     {
         if (string.Compare(p.Kind, ProjectKinds.vsProjectKindSolutionFolder) == 0)
         {
             CollectNestedProjects(p);
         }
         else
         {
             SolutionProject sp = new SolutionProject()
             {
                 ProjectName       = p.Name,
                 ProjectUniqueName = p.UniqueName,
                 ProjectRef        = p
             };
             ComboItemsSourceProjects.Add(sp);
         }
     }
 }
예제 #11
0
        internal string EvaluateProjectFolderPath(Solution solution, SolutionProject project, int folderLevels = -1)
        {
            if (folderLevels < 0)
            {
                folderLevels = _options.SolutionFolderLevels;
            }

            if (project.IsFolder)
            {
                string solutionFolderPath = solution.GetSolutionFolderPath(project);
                return(solutionFolderPath.Contains(".") ? solutionFolderPath.Substring(0, solutionFolderPath.LastIndexOf('.')) : null);
            }
            else
            {
                string folderBaseName = SkipCommonLevels(EvaluateFolderBaseName(project));
                int    subnameCount   = 0;
                int    index          = 0;
                while (subnameCount < folderLevels && index >= 0)
                {
                    subnameCount++;
                    index = folderBaseName.IndexOf('.', index + 1);
                }
                if (index < 0)
                {
                    index = folderBaseName.Length;
                }
                return(folderBaseName.Substring(0, index));
            }
        }
예제 #12
0
        private static string GetProjectObjOutputDirectoryPath(
            this SolutionProject project,
            IProjectConfiguration config)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var relativeBase      = config.GetRelativeSlnFilePath().GetDirectory();
            var baseOutputPath    = $"{relativeBase.FullPath}/**/{project.Name}";
            var baseBinOutputPath = $"{baseOutputPath}/obj";

            var configPath    = string.IsNullOrWhiteSpace(config.Configuration) ? "/**" : $"/{config.Configuration}";
            var frameworkPath = string.IsNullOrWhiteSpace(config.Framework) ? string.Empty : $"/{config.Framework}";

            var binPath = $"{baseBinOutputPath}{configPath}{frameworkPath}";

            return(binPath);
        }
예제 #13
0
 private void textBoxVisualStudioSolutionPath_TextChanged(object sender, EventArgs e)
 {
     if (textBoxVisualStudioSolutionPath.Text.Length > 5)
     {
         try
         {
             FileInfo solutionFile = new FileInfo(textBoxVisualStudioSolutionPath.Text);
             BindingList <SolutionProject> projects = new BindingList <SolutionProject>();
             foreach (DirectoryInfo dir in solutionFile.Directory.GetDirectories())
             {
                 if (!dir.Name.StartsWith("."))
                 {
                     //checkedListBox1.Items.Add(dir.Name);
                     SolutionProject project = new SolutionProject();
                     project.Name = dir.Name;
                     projects.Add(project);
                 }
             }
             dataGridView1.DataSource = projects;
         }
         catch (Exception ex)
         {
             Debug.Print(ex.Message);
         }
     }
 }
예제 #14
0
        private void ParseProjectSection(SolutionProject project, List <string> lines, ref int lineIndex)
        {
            var section = new SolutionProject.Section();

            project.Sections.Add(section);
            bool more = true;

            while (more && lineIndex < lines.Count)
            {
                string line = lines[lineIndex++];
                if (line.StartsWith("\tEndProjectSection"))
                {
                    more = false;
                }
                else if (line.StartsWith("\tProjectSection"))
                {
                    int index = line.IndexOf('(') + 1;
                    section.SectionName = line.Substring(index, line.IndexOf(')', index) - index);
                    index = line.IndexOf("= ", index) + 2;
                    section.PrePostProject = line.Substring(index);
                }
                else
                {
                    section.SectionItems.Add(line.Trim());
                }
            }
        }
 public NugetReference(string package, string version, MicroserviceItem service, SolutionProject project)
 {
     Name    = package;
     Version = version;
     Latest  = FindLatest();
     Project = project;
     Service = service;
 }
		public void Process(SolutionFile solutionFile)
		{
			var basePath = solutionFile.FullPath.Parent;
			var relativePath = absolutePath.PathFrom(basePath);
			var project = new SolutionProject(relativePath, basePath, SolutionProject.CsProjProject, fileSystem);
			// It would be nicer if we could figure out the type by reading the destination file.
			solutionFile.Add(project);
		}
 public NugetReference(ProjectItemGroupPackageReference @ref, MicroserviceItem service, SolutionProject project)
 {
     Name    = @ref.Include;
     Version = @ref.Version;
     Latest  = FindLatest();
     Project = project;
     Service = service;
 }
        /// <summary>
        /// Gets the output assembly path for a SolutionProject
        /// </summary>
        /// <param name="solutionProject">The solutionproject</param>
        /// <param name="project">The parsed project</param>
        /// <returns>The SolutionProject output assembly path</returns>
        /// <example>
        /// Gets an absolute assembly path for a project
        /// <code>
        /// var projects = ParseSolution(new FilePath("test.sln")).GetProjects();
        /// project[0].GetAssemblyFilePath();
        /// </code>
        /// </example>
        public static FilePath GetAssemblyFilePath(this SolutionProject solutionProject, CustomProjectParserResult project)
        {
            solutionProject.ThrowIfNull(nameof(solutionProject));
            project.ThrowIfNull(nameof(project));

            var assemblyFilePath = project.GetAssemblyFilePath();

            return(solutionProject.Path.GetDirectory().CombineWithFilePath(assemblyFilePath));
        }
예제 #19
0
        public override void UiBtnCommandAction(Object param)
        {
            if (string.IsNullOrWhiteSpace(UiCommandProppertyName))
            {
                return;
            }
            if (SelectedCodeElement == null)
            {
                return;
            }
            if (SelectedCodeElement.CodeElementRef == null)
            {
                return;
            }
            CodeClass cc = SelectedCodeElement.CodeElementRef as CodeClass;

            if (SelectedViewModel != null)
            {
                SolutionProject prj = ComboItemsSourceProjects.Where(p => string.Equals(p.ProjectUniqueName, SelectedViewModel.RootNodeProjectName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (prj != null)
                {
                    if (!string.Equals(SelectedProject.ProjectUniqueName, prj.ProjectUniqueName, StringComparison.OrdinalIgnoreCase))
                    {
                        if (SelectedProject.ProjectRef.Object is VSProject)
                        {
                            (SelectedProject.ProjectRef.Object as VSProject).References.AddProject(prj.ProjectRef);
                            SelectedProject.ProjectRef.Save();
                        }
                    }
                }
            }



            //cc.AddProperty(UiCommandProppertyName , UiCommandProppertyName, "System.Data.Entity.DbSet<" + SelectedViewModelRootClass + ">", -1, vsCMAccess.vsCMAccessPublic, null);
            CodeProperty codeProperty =
                cc.AddProperty(UiCommandProppertyName, UiCommandProppertyName, "DbSet<" + SelectedViewModelRootClass + ">", -1, vsCMAccess.vsCMAccessPublic, null);
            EditPoint editPoint = codeProperty.Getter.StartPoint.CreateEditPoint();

            editPoint.Delete(codeProperty.Getter.EndPoint);
            editPoint.Insert("get ;");

            editPoint = codeProperty.Setter.StartPoint.CreateEditPoint();
            editPoint.Delete(codeProperty.Setter.EndPoint);
            editPoint.Insert("set ;");
            if (cc.ProjectItem != null)
            {
                if (cc.ProjectItem.IsDirty)
                {
                    cc.ProjectItem.Save();
                }
            }



            DoAnaliseDbContext();
        }
예제 #20
0
        public static ProjectModel ToModel(this SolutionProject project, string startsWith, bool showSystemReferences, bool showMissingOnly)
        {
            var model = new ProjectModel {
                Name = project.ProjectName, Id = Guid.Parse(project.ProjectGuid)
            };

            model.Children = project.GetReferences(model, startsWith, showSystemReferences, showMissingOnly);
            return(model);
        }
예제 #21
0
        private void ProcessConfigurationPlatformMapping(SolutionProject solutionProject, UnityConfigurationType configType, CompilationPlatformInfo platform, IReadOnlyDictionary <BuildTarget, CompilationPlatformInfo> enabledPlatforms)
        {
            ConfigurationPlatformPair configPair = new ConfigurationPlatformPair(configType, platform.Name);

            solutionProject.ConfigurationPlatformMapping.Add(configPair, new ProjectConfigurationPlatformMapping()
            {
                ConfigurationPlatform = configPair,
                EnabledForBuild       = enabledPlatforms.ContainsKey(platform.BuildTarget)
            });
        }
예제 #22
0
        private void MergeSolutionFolders(Solution solution)
        {
            var solutionFolders = GenerateSolutionFolders(solution);

            foreach (var project in solution.Projects)
            {
                if (project.IsFolder)
                {
                    string solutionFolderPath = solution.GetSolutionFolderPath(project);
                    if (solutionFolders.Contains(solutionFolderPath))
                    {
                        solutionFolders.Remove(solutionFolderPath);
                    }
                }
            }

            // Add new solution folders that are not present in current solution
            var solutionFolderMap = new Dictionary <string, Guid>();

            foreach (var solutionFolder in solutionFolders)
            {
                SolutionProject parentProject = null;
                int             index         = solutionFolder.LastIndexOf('.');
                if (index > 0)
                {
                    parentProject = solution.FindFolderWithPath(solutionFolder.Substring(0, index));
                }

                var project = new SolutionProject()
                {
                    ProjectTypeId = ProjectType.SolutionFolder.ProjectGuid,
                    ProjectId     = Guid.NewGuid(),
                    ParentProject = parentProject,
                    Name          = solution.GetSolutionFolderName(solutionFolder),
                    Path          = solution.GetSolutionFolderName(solutionFolder),
                };

                solution.Projects.Add(project);
                solutionFolderMap.Add(solutionFolder, project.ProjectId);
            }

            // Now attach parents to projects
            foreach (var project in solution.Projects)
            {
                string folderPath = EvaluateProjectFolderPath(solution, project, _options.SolutionFolderLevels);
                if (folderPath != null)
                {
                    SolutionProject parentProject = solution.FindFolderWithPath(folderPath);
                    if (parentProject != null)
                    {
                        project.ParentProject = parentProject;
                    }
                }
            }
        }
예제 #23
0
        private void CreateTaskDatabase(SolutionProject solutionProject)
        {
            var projectDatabase = _taskListManager.CreateProjectDatabase(solutionProject.Name, solutionProject.ParentDirectory);

            if (projectDatabase == true)
            {
                // Refresh the loaded list to reflect the update because I'm too lazy
                // to wire up all the annoying stuff to update in place
                LoadSolutionProjects();
            }
        }
예제 #24
0
        public static void UpdateDependencies(SolutionProject project, bool directDependencies, bool flattenedDependencies)
        {
            if (flattenedDependencies)
            {
                project.FlattenedDependencies.Clear();
            }
            if (directDependencies)
            {
                project.DirectDependencies.Clear();
            }
            var projectAssetsJsonPath = Path.Combine(project.FullPath.GetFullDirectory(), @"obj", LockFileFormat.AssetsFileName);

            if (File.Exists(projectAssetsJsonPath))
            {
                var format        = new LockFileFormat();
                var projectAssets = format.Read(projectAssetsJsonPath);

                // Update dependencies
                if (flattenedDependencies)
                {
                    foreach (var library in projectAssets.Libraries)
                    {
                        var projectDependency = new Dependency(library.Name, library.Version.ToPackageVersion(), library.Type == "project" ? DependencyType.Project : DependencyType.Package)
                        {
                            MSBuildProject = library.Type == "project" ? library.MSBuildProject : null
                        };
                        project.FlattenedDependencies.Add(projectDependency);
                        // Try to resolve package if already loaded
                        projectDependency.Package = project.Session.Packages.Find(projectDependency);
                    }
                }

                if (directDependencies)
                {
                    foreach (var projectReference in projectAssets.PackageSpec.RestoreMetadata.TargetFrameworks.First().ProjectReferences)
                    {
                        var projectName = new UFile(projectReference.ProjectUniqueName).GetFileNameWithoutExtension();
                        project.DirectDependencies.Add(new DependencyRange(projectName, null, DependencyType.Project)
                        {
                            MSBuildProject = projectReference.ProjectPath
                        });
                    }

                    foreach (var dependency in projectAssets.PackageSpec.TargetFrameworks.First().Dependencies)
                    {
                        if (dependency.AutoReferenced)
                        {
                            continue;
                        }
                        project.DirectDependencies.Add(new DependencyRange(dependency.Name, dependency.LibraryRange.VersionRange.ToPackageVersionRange(), DependencyType.Package));
                    }
                }
            }
        }
예제 #25
0
 public virtual void CollectProjectClasses(SolutionProject sp)
 {
     SelectedCodeElement = null;
     if (ComboItemsSourceCodeElements == null)
     {
         ComboItemsSourceCodeElements = new ObservableCollection <SolutionCodeElement>();
     }
     else
     {
         ComboItemsSourceCodeElements.Clear();
     }
 }
예제 #26
0
        public async Task <BaseDto> Handle(AddProjectCommand request, CancellationToken cancellationToken)
        {
            if (await _solutionProjectRepository.ExistProjectName(request.SolutionId, request.EnvId, request.Name))
            {
                return new BaseDto()
                       {
                           IsSuccess = false, Msg = "项目名已存在"
                       }
            }
            ;
            if (await _solutionProjectRepository.ExistAppId(request.SolutionId, request.EnvId, request.AppId))
            {
                return new BaseDto()
                       {
                           IsSuccess = false, Msg = "AppId已存在"
                       }
            }
            ;

            var projectEntity = new SolutionProject()
            {
                SolutionId    = request.SolutionId,
                SolutionEnvId = request.EnvId,
                Name          = request.Name,
                CName         = request.CName,
                AppId         = request.AppId
            };
            await _solutionProjectRepository.AddAsync(projectEntity, cancellationToken);

            var changedRow = await _unitOfWork.SaveChangesAsync(cancellationToken);

            if (changedRow > 0)
            {
                await _mediator.Publish(new ProjectCreatedEvent()
                {
                    ProjectId = projectEntity.Id
                }, cancellationToken);

                return(new BaseDto()
                {
                    IsSuccess = true, Msg = "Handler Success"
                });
            }
            else
            {
                return(new BaseDto()
                {
                    IsSuccess = false, Msg = "添加项目失败"
                });
            }
        }
    }
}
예제 #27
0
 public bool ShouldApply(SolutionProject project)
 {
     if (project.IsFolder) {
         return true;
     }
     foreach (var validProject in patterns) {
         if (validProject.IsMatch(project.Name)) {
             return true;
         }
     }
     return false;
 }
예제 #28
0
        public void Alter(TemplatePlan plan)
        {
            this._substitutions.Set("%INSTRUCTIONS%", plan.GetInstructions());
            plan.Logger.StartProject(this._alterations.Count);
            plan.StartProject(this);
            this._substitutions.Trace(plan.Logger);
            SolutionProject reference = plan.Solution.FindProject(this._projectName);

            if (reference == null)
            {
                if (FubuCore.StringExtensions.IsEmpty(this.ProjectTemplateFile))
                {
                    plan.Logger.Trace("Creating project {0} from the default template", new object[]
                    {
                        this._projectName
                    });
                    reference = plan.Solution.AddProject(this._projectName);
                }
                else
                {
                    plan.Logger.Trace("Creating project {0} from template at {1}", new object[]
                    {
                        this._projectName,
                        this.ProjectTemplateFile
                    });
                    reference = plan.Solution.AddProjectFromTemplate(this._projectName, this.ProjectTemplateFile);
                }
                reference.Project.AssemblyName = (reference.Project.RootNamespace = this.ProjectName);
                if (this.DotNetVersion != null)
                {
                    reference.Project.DotNetVersion = this.DotNetVersion;
                }
            }
            string projectDirectory = reference.Project.ProjectDirectory;

            plan.FileSystem.CreateDirectory(projectDirectory);
            this._relativePath = FubuCore.StringExtensions.PathRelativeTo(reference.Project.FileName, plan.Root).Replace("\\", "/");
            this._substitutions.Set("%PROJECT_PATH%", this._relativePath);
            this._substitutions.Set("%PROJECT_FOLDER%", GenericEnumerableExtensions.Join(this._relativePath.Split(new char[]
            {
                '/'
            }).Reverse <string>().Skip(1).Reverse <string>(), "/"));
            GenericEnumerableExtensions.Each <IProjectAlteration>(this._alterations, delegate(IProjectAlteration x)
            {
                plan.Logger.TraceAlteration(this.ApplySubstitutionsRaw(x.ToString(), null));
                x.Alter(reference.Project, this);
            });
            this.Substitutions.WriteTo(FubuCore.StringExtensions.AppendPath(projectDirectory, new string[]
            {
                Substitutions.ConfigFile
            }));
            plan.Logger.EndProject();
        }
        public void SetUp()
        {
            var fileSystem = new FileSystem();
            fileSystem.CreateDirectory("Solution1");
            fileSystem.CleanDirectory("Solution1");

            fileSystem.CreateDirectory(@"Solution1\docs");
            fileSystem.CreateDirectory(@"Solution1\harness");
            fileSystem.Copy("SlickGridHarness.csproj.fake", @"Solution1\harness\SlickGridHarness.csproj");
            fileSystem.Copy("FubuMVC.SlickGrid.Docs.csproj.fake", @"Solution1\docs\FubuMVC.SlickGrid.Docs.csproj");

            theSolutionProject = new SolutionProject("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"FubuMVC.SlickGrid\", \"FubuMVC.SlickGrid\\FubuMVC.SlickGrid.csproj\", \"{A67A0CE1-E4C2-45FC-9019-829D434B2CC4}\"", "Solution1");
        }
예제 #30
0
        public static SolutionProject BuildSolutionProject([NotNull] this string solutionProjectLine)
        {
            var solutionProject = new SolutionProject();

            var solutionProjectLineParts = solutionProjectLine.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).TrimList();

            solutionProject.ProjectTypeId   = solutionProjectLineParts.GetProjectTypeIdString();
            solutionProject.ProjectId       = solutionProjectLineParts.GetProjectIdString();
            solutionProject.ProjectName     = solutionProjectLineParts.GetProjectName();
            solutionProject.ProjectFileName = solutionProjectLineParts.GetProjectFileName();

            return(solutionProject);
        }
예제 #31
0
        private SolutionProject GetDependencyProjectReference(string projectName, string relativePath)
        {
            SolutionProject toReturn = new SolutionProject(config.DependenciesProjectGuid, SolutionProject.CSharpProjectTypeGuid, projectName, relativePath, null, CSProjects.Values.Select(t => t.Guid));

            void SetMapping(ConfigurationPlatformPair configPlatform) => toReturn.ConfigurationPlatformMapping.Add(configPlatform, new ProjectConfigurationPlatformMapping()
            {
                ConfigurationPlatform = configPlatform, EnabledForBuild = true
            });

            SetMapping(new ConfigurationPlatformPair("Debug", "Any CPU"));
            SetMapping(new ConfigurationPlatformPair("Release", "Any CPU"));

            return(toReturn);
        }
예제 #32
0
        internal static IEnumerable <string> GetProjectOutputFileNamePatterns(
            this SolutionProject project)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            yield return($"{project.Name}.dll");

            yield return($"{project.Name}.xml");

            yield return($"{project.Name}.pdb");
        }
예제 #33
0
        public void SetUp()
        {
            var fileSystem = new FileSystem();

            fileSystem.CreateDirectory("Solution1");
            fileSystem.CleanDirectory("Solution1");

            fileSystem.CreateDirectory(@"Solution1\docs");
            fileSystem.CreateDirectory(@"Solution1\harness");
            fileSystem.Copy("SlickGridHarness.csproj.fake", @"Solution1\harness\SlickGridHarness.csproj");
            fileSystem.Copy("FubuMVC.SlickGrid.Docs.csproj.fake", @"Solution1\docs\FubuMVC.SlickGrid.Docs.csproj");

            theSolutionProject = new SolutionProject("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"FubuMVC.SlickGrid\", \"FubuMVC.SlickGrid\\FubuMVC.SlickGrid.csproj\", \"{A67A0CE1-E4C2-45FC-9019-829D434B2CC4}\"", "Solution1");
        }
예제 #34
0
        public static string Path(this SolutionProject projEnum)
        {
            switch (projEnum)
            {
            case SolutionProject.Website: return("Website");

            case SolutionProject.Domain: return("Domain");

            case SolutionProject.Model: return("M#\\Model");

            case SolutionProject.UI: return("M#\\UI");

            default: throw new NotSupportedException();
            }
        }
예제 #35
0
        public string GetSolutionFolderPath(SolutionProject project)
        {
            if (!project.IsFolder)
            {
                throw new InvalidOperationException("GetSolutionFolderPath requires folder project");
            }

            string path = project.Name;
            Guid? parentProjectId = project.ParentProjectId;
            while (parentProjectId != null)
            {
                var parentProject = this.FindProject(parentProjectId.Value);
                if (parentProject != null)
                {
                    path = string.Format("{0}.{1}", parentProject.Path, path);
                    parentProjectId = parentProject.ParentProjectId;
                }
            }
            return path;
        }
예제 #36
0
        private TreeNode CreateProjectNode(TreeNode root, SolutionProject project)
        {
            if (this.projectNodes.ContainsKey(project))
                return projectNodes[project];

            var parent = root;
            if (project.ParentProject != null)
            {
                parent = CreateProjectNode(root, project.ParentProject);
            }

            var node = new TreeNode(project.Name);
            node.Tag = project;
            var projectType = project.IsFolder ? ProjectType.SolutionFolder : ProjectTypes.Find(project.ProjectTypeId);
            node.ImageKey = ProjectIcons[projectType];
            node.SelectedImageKey = node.ImageKey;
            parent.Nodes.Add(node);
            this.projectNodes.Add(project, node);
            return node;
        }
예제 #37
0
 public IEnumerable<string> GetProjectPaths(string solutionPath)
 {
     if (SolutionParser == null)
     {
         throw new InvalidOperationException("Can not find type 'Microsoft.Build.Construction.SolutionParser' are you missing a assembly reference to 'Microsoft.Build.dll'?");
     }
     var solutionParser = SolutionParser.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)[0].Invoke(null);
     using (var streamReader = new StreamReader(solutionPath))
     {
         SolutionReader.SetValue(solutionParser, streamReader, null);
         ParseSolution.Invoke(solutionParser, null);
     }
     var result = new List<string>();
     var array = (Array)Projects.GetValue(solutionParser, null);
     var solutionProject = new SolutionProject();
     for (int i = 0; i < array.Length; i++)
     {
         result.Add(solutionProject.GetRelativePath(array.GetValue(i)));
     }
     return result;
 }
예제 #38
0
        internal string EvaluateProjectFolderPath(Solution solution, SolutionProject project, int folderLevels = -1)
        {
            if (folderLevels < 0)
                folderLevels = _options.SolutionFolderLevels;

            if (project.IsFolder)
            {
                string solutionFolderPath = solution.GetSolutionFolderPath(project);
                return solutionFolderPath.Contains(".") ? solutionFolderPath.Substring(0, solutionFolderPath.LastIndexOf('.')) : null;
            }
            else
            {
                string folderBaseName = SkipCommonLevels(EvaluateFolderBaseName(project));
                int subnameCount = 0;
                int index = 0;
                while (subnameCount < folderLevels && index >= 0)
                {
                    subnameCount++;
                    index = folderBaseName.IndexOf('.', index + 1);
                }
                if (index < 0)
                {
                    index = folderBaseName.Length;
                }
                return folderBaseName.Substring(0, index);
            }
        }
예제 #39
0
        private void ParseProjects(Solution solution, List<string> lines, ref int lineIndex)
        {
            bool more = true;
            while (more && lineIndex < lines.Count)
            {
                string line = lines[lineIndex++];
                if (!line.StartsWith("Project("))
                {
                    more = false;
                }
                else
                {
                    var project = new SolutionProject();
                    int index = line.IndexOf('{') + 1;
                    project.ProjectTypeId = new Guid(line.Substring(index, line.IndexOf('}', index) - index));
                    index = line.LastIndexOf('{') + 1;
                    project.ProjectId = new Guid(line.Substring(index, line.IndexOf('}', index) - index));
                    index = line.IndexOf("= \"") + 3;
                    project.Name = line.Substring(index, line.IndexOf('\"', index) - index);
                    index = line.IndexOf(", \"", index) + 3;
                    project.Path = line.Substring(index, line.IndexOf('\"', index) - index);

                    ParseProjectSections(project, lines, ref lineIndex);

                    solution.Projects.Add(project);
                }

                if (!more)
                {
                    lineIndex--;
                }
            }
        }
예제 #40
0
        private void MergeSolutionFolders(Solution solution)
        {
            var solutionFolders = GenerateSolutionFolders(solution);
            foreach (var project in solution.Projects)
            {
                if (project.IsFolder)
                {
                    string solutionFolderPath = solution.GetSolutionFolderPath(project);
                    if (solutionFolders.Contains(solutionFolderPath))
                    {
                        solutionFolders.Remove(solutionFolderPath);
                    }
                }
            }

            // Add new solution folders that are not present in current solution
            var solutionFolderMap = new Dictionary<string, Guid>();
            foreach (var solutionFolder in solutionFolders)
            {
                SolutionProject parentProject = null;
                int index = solutionFolder.LastIndexOf('.');
                if (index > 0)
                {
                    parentProject = solution.FindFolderWithPath(solutionFolder.Substring(0, index));
                }

                var project = new SolutionProject()
                {
                    ProjectTypeId = ProjectType.SolutionFolder.ProjectGuid,
                    ProjectId = Guid.NewGuid(),
                    ParentProject = parentProject,
                    Name = solution.GetSolutionFolderName(solutionFolder),
                    Path = solution.GetSolutionFolderName(solutionFolder),
                };

                solution.Projects.Add(project);
                solutionFolderMap.Add(solutionFolder, project.ProjectId);
            }

            // Now attach parents to projects
            foreach (var project in solution.Projects)
            {
                string folderPath = EvaluateProjectFolderPath(solution, project, _options.SolutionFolderLevels);
                if (folderPath != null)
                {
                    SolutionProject parentProject = solution.FindFolderWithPath(folderPath);
                    if (parentProject != null)
                    {
                        project.ParentProject = parentProject;
                    }
                }
            }
        }
예제 #41
0
        private void ParseProjectSection(SolutionProject project, List<string> lines, ref int lineIndex)
        {
            var section = new SolutionProject.Section();
            project.Sections.Add(section);
            bool more = true;
            while (more && lineIndex < lines.Count)
            {
                string line = lines[lineIndex++];
                if (line.StartsWith("\tEndProjectSection"))
                {
                    more = false;
                }
                else if (line.StartsWith("\tProjectSection"))
                {
                    int index = line.IndexOf('(') + 1;
                    section.SectionName = line.Substring(index, line.IndexOf(')', index) - index);
                    index = line.IndexOf("= ", index) + 2;
                    section.PrePostProject = line.Substring(index);

                }
                else
                {
                    section.SectionItems.Add(line.Trim());
                }
            }
        }
예제 #42
0
 private void ScanProjectReferences(SolutionProject project, IList<SolutionProject> referencedProjects, SolutionFileVersion solutionFileVersion,
     IEnumerable<string> includeFilter, IEnumerable<string> excludeFilter)
 {
     var projectAnalyzer = new ProjectAnalyzer(Path.Combine(this._options.SolutionFolderPath, project.Path));
     var projectReferences = projectAnalyzer.GetProjectReferences();
     foreach (var projectReference in projectReferences)
     {
         if (File.Exists(projectReference.Path))
         {
             ProcessProjectFile(projectReference.Path, referencedProjects, includeFilter, excludeFilter, projectAnalyzer, true);
             ScanProjectReferences(projectReference, referencedProjects, solutionFileVersion, includeFilter, excludeFilter);
         }
     }
 }
예제 #43
0
 private void HookupGoose(IVsProject projectHierarchy)
 {
     try
     {
         var solutionProject = new SolutionProject(this.solution, projectHierarchy);
         this.ConnectProjectEventListeners(solutionProject);
     }
     catch (Exception ex)
     {
         //this.outputService.Handle(new CommandOutput("goose", "failed to configure actions", ex.ToString(), CommandOutputItemType.Message));
     }
 }
예제 #44
0
 private void ParseProjectSections(SolutionProject project, List<string> lines, ref int lineIndex)
 {
     bool more = true;
     while (more && lineIndex < lines.Count)
     {
         string line = lines[lineIndex++];
         if (line.StartsWith("EndProject"))
         {
             more = false;
         }
         else if (line.StartsWith("\tProjectSection"))
         {
             --lineIndex;
             ParseProjectSection(project, lines, ref lineIndex);
         }
     }
 }
예제 #45
0
        private void WriteProject(StreamWriter writer, SolutionProject project)
        {
            writer.Write(string.Format(@"Project(""{{{0}}}"") = ", project.ProjectTypeId.ToString().ToUpper()));
            writer.WriteLine(string.Format(@"""{0}"", ""{1}"", ""{{{2}}}""",
                project.Name, project.Path, project.ProjectId.ToString().ToUpper()));

            foreach (var section in project.Sections)
            {
                writer.WriteLine(string.Format("\tProjectSection({0}) = {1}", section.SectionName, section.PrePostProject));
                foreach (string item in section.SectionItems)
                {
                    writer.WriteLine(string.Format("\t\t{0}", item));
                }
                writer.WriteLine(string.Format("\tEndProjectSection"));
            }
            writer.WriteLine("EndProject");
        }
예제 #46
0
        private string EvaluateFolderBaseName(SolutionProject project)
        {
            string projectName = RemoveCommonPrefixes(project.Name);
            if (_options.FolderNamingMode == SolutionFolderNamingMode.Project)
                return projectName;

            string assemblyName = RemoveCommonPrefixes(new ProjectAnalyzer(Path.Combine(_options.SolutionFolderPath, project.Path)).GetAssemblyName());
            if (string.IsNullOrEmpty(assemblyName))
                return projectName;

            if (_options.FolderNamingMode == SolutionFolderNamingMode.Assembly)
                return assemblyName;

            int projectNameParts = projectName.Split('.').Count();
            int assemblyNameParts = assemblyName.Split('.').Count();
            if (projectNameParts > assemblyNameParts)
                return projectName;
            if (assemblyNameParts > projectNameParts)
                return assemblyName;
            if (projectName.Length > assemblyName.Length)
                return projectName;
            if (assemblyName.Length > projectName.Length)
                return assemblyName;
            return projectName;
        }
예제 #47
0
        private void ProcessProjectFile(string projectPath, IList<SolutionProject> projects,
            IEnumerable<string> includeFilter, IEnumerable<string> excludeFilter, ProjectAnalyzer projectAnalyzer, bool allowDuplicates)
        {
            ++this.NumberOfProjectsFound;
            string message = string.Format("Found project {0}", Path.GetFileNameWithoutExtension(projectPath));

            bool skip = false;
            if (includeFilter.Any() && !ProjectHasMatch(projectPath, includeFilter))
            {
                skip = true;
            }
            if (excludeFilter.Any() && ProjectHasMatch(projectPath, excludeFilter))
            {
                skip = true;
            }

            if (skip)
            {
                ++this.NumberOfProjectsSkipped;
                message += " (skipped)";
            }
            else
            {
                var project = new SolutionProject();
                project.ProjectTypeId = ProjectTypes.Find(Path.GetExtension(projectPath).Substring(1)).ProjectGuid;
                project.ProjectId = projectAnalyzer.GetProjectId();
                project.Name = Path.GetFileNameWithoutExtension(projectPath);
                project.Path = Utils.GetRelativePath(this._options.SolutionFolderPath, projectPath);

                if (!allowDuplicates && projects.Any(x => x.Name == project.Name))
                {
                    throw new InvalidOperationException(string.Format("Duplicate project: {0}. All projects should have unique names across the solution.", project.Name));
                }

                projects.Add(project);
            }

            this._logger.Write(message);
        }
예제 #48
0
 public bool ShouldApply(SolutionProject project)
 {
     return !project.IsFolder;
 }