Exemple #1
0
 NuGitRepository(NuGitWorkspace workspace, GitRepositoryName name)
     : base(
         IOPath.Combine(
             Guard.NotNull(workspace, nameof(workspace)).RootPath,
             Guard.NotNull(name, nameof(name))))
 {
     Workspace = workspace;
 }
Exemple #2
0
        GetRepository(GitRepositoryName name)
        {
            var repository = FindRepository(name);

            if (repository == null)
            {
                throw new ArgumentException(Invariant($"No '{name}' repository in workspace"), nameof(name));
            }
            return(repository);
        }
 ProduceRepository(ProduceWorkspace workspace, GitRepositoryName name)
     : base(
         IOPath.Combine(
             Guard.NotNull(workspace, nameof(workspace)).Path,
             Guard.NotNull(name, nameof(name))))
 {
     Workspace      = workspace;
     DotProducePath = IOPath.Combine(Path, ".produce");
     WorkDirectory  = IOPath.Combine(Workspace.GetProduceDirectory(), Name);
 }
Exemple #4
0
        GetRepository(GitRepositoryName name)
        {
            var repository = FindRepository(name);

            if (repository == null)
            {
                throw new ArgumentException(
                          StringExtensions.FormatInvariant(
                              "No repository named '{0}' in workspace",
                              name),
                          "name");
            }
            return(repository);
        }
Exemple #5
0
        FindRepository(GitRepositoryName name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("Blank", "name");
            }

            if (!GitRepository.IsRepository(Path.Combine(RootPath, name)))
            {
                return(null);
            }
            return(new NuGitRepository(this, name));
        }
Exemple #6
0
 FindRepository(GitRepositoryName name)
 {
     Guard.NotNull(name, nameof(name));
     return(FindRepositories().FirstOrDefault(r => r.Name == name));
 }
Exemple #7
0
        Install(
            NuGitRepository repository,
            VisualStudioSolution sln,
            GitRepositoryName dependencyName,
            string folderName,
            string folderId
            )
        {
            var workspace = repository.Workspace;

            var slnLocalPath           = PathExtensions.GetPathFromAncestor(sln.Path, repository.Path);
            var slnLocalPathComponents = PathExtensions.Split(slnLocalPath);
            var slnToWorkspacePath     = Path.Combine(Enumerable.Repeat("..", slnLocalPathComponents.Length).ToArray());

            var dependencyRepository = workspace.GetRepository(dependencyName);

            var dependencySln = dependencyRepository.FindVisualStudioSolution();

            if (dependencySln == null)
            {
                return;
            }

            var dependencyProjects = FindDependencyProjects(dependencyRepository, dependencySln);

            if (dependencyProjects.Count == 0)
            {
                return;
            }

            using (LogicalOperation.Start($"Installing projects from {dependencyName}"))
            {
                // TODO Consider configurations in each individual dependency project, not just the solution
                var configurationsInCommon =
                    sln.SolutionConfigurations.Intersect(dependencySln.SolutionConfigurations)
                    .OrderBy(s => s)
                    .ToList();

                var folder =
                    folderId != null
                ? sln.AddSolutionFolder(folderName, folderId)
                : sln.AddSolutionFolder(folderName);

                foreach (var project in dependencyProjects)
                {
                    using (LogicalOperation.Start($"Installing {project.Name}"))
                    {
                        var projectLocalPath =
                            PathExtensions.GetPathFromAncestor(project.AbsoluteLocation, dependencyRepository.Path);

                        //
                        // Add reference to the dependency project
                        //
                        sln.AddProjectReference(
                            project.TypeId,
                            project.Name,
                            Path.Combine(slnToWorkspacePath, dependencyName, projectLocalPath),
                            project.Id);

                        //
                        // Put it in the dependency's solution folder
                        //
                        sln.AddNestedProject(project.Id, folder.Id);

                        //
                        // Add solution -> project configuration mappings
                        //
                        foreach (string configuration in configurationsInCommon)
                        {
                            sln.AddProjectConfiguration(project.Id, configuration, "ActiveCfg", configuration);
                            sln.AddProjectConfiguration(project.Id, configuration, "Build.0", configuration);
                        }
                    }
                }
            }
        }