Ejemplo n.º 1
0
        private async Task RemoveUnnecessaryProjectsAsync(string solutionDirectory, ModuleWithMastersInfo module,
                                                          string[] projectFiles)
        {
            var moduleDirectory    = Path.Combine(solutionDirectory, "modules", module.Name);
            var moduleSolutionFile = Directory.GetFiles(moduleDirectory, "*.sln", SearchOption.TopDirectoryOnly).First();
            var isProjectTiered    = await IsProjectTiered(projectFiles);

            var webPackagesWillBeAddedToBlazorServerProject = false;

            var blazorProject = projectFiles.FirstOrDefault(p => p.EndsWith(".Blazor.csproj"));

            if (blazorProject == null)
            {
                await RemoveProjectByTarget(module, moduleSolutionFile, NuGetPackageTarget.Blazor, isProjectTiered);
                await RemoveProjectByTarget(module, moduleSolutionFile, NuGetPackageTarget.BlazorServer, isProjectTiered);
                await RemoveProjectByTarget(module, moduleSolutionFile, NuGetPackageTarget.BlazorWebAssembly, isProjectTiered);
                await RemoveProjectByPostFix(module, moduleSolutionFile, "src", ".Blazor");
            }
            else
            {
                var isBlazorServer = BlazorProjectTypeChecker.IsBlazorServerProject(blazorProject);

                if (isBlazorServer)
                {
                    await RemoveProjectByTarget(module, moduleSolutionFile, NuGetPackageTarget.BlazorWebAssembly, isProjectTiered);

                    webPackagesWillBeAddedToBlazorServerProject = module.NugetPackages.All(np => np.Target != NuGetPackageTarget.BlazorServer && np.TieredTarget != NuGetPackageTarget.BlazorServer);
                }
                else
                {
                    await RemoveProjectByTarget(module, moduleSolutionFile, NuGetPackageTarget.BlazorServer, isProjectTiered);
                }
            }

            if (!projectFiles.Any(p => p.EndsWith(".Web.csproj")) && !webPackagesWillBeAddedToBlazorServerProject)
            {
                await RemoveProjectByTarget(module, moduleSolutionFile, NuGetPackageTarget.Web, isProjectTiered);
            }

            if (!projectFiles.Any(p => p.EndsWith(".MongoDB.csproj")))
            {
                await RemoveProjectByTarget(module, moduleSolutionFile, NuGetPackageTarget.MongoDB, isProjectTiered);
                await RemoveProjectByPostFix(module, moduleSolutionFile, "test", ".MongoDB.Tests");
            }

            if (!projectFiles.Any(p => p.EndsWith(".EntityFrameworkCore.csproj")))
            {
                await RemoveProjectByTarget(module, moduleSolutionFile, NuGetPackageTarget.EntityFrameworkCore, isProjectTiered);
                await RemoveProjectByPostFix(module, moduleSolutionFile, "test", ".EntityFrameworkCore.Tests");
                await RemoveProjectByPostFix(module, moduleSolutionFile, "test", ".Application.Tests");

                ChangeDomainTestReferenceToMongoDB(module, moduleSolutionFile);
            }
        }
Ejemplo n.º 2
0
        private static bool SouldWebPackagesBeAddedToBlazorServerProject(ModuleWithMastersInfo module, string[] projectFiles)
        {
            var blazorProject = projectFiles.FirstOrDefault(p => p.EndsWith(".Blazor.csproj"));

            if (blazorProject == null)
            {
                return(false);
            }

            var isBlazorServerProject = BlazorProjectTypeChecker.IsBlazorServerProject(blazorProject);

            return(isBlazorServerProject && module.NugetPackages.All(np => np.Target != NuGetPackageTarget.BlazorServer && np.TieredTarget != NuGetPackageTarget.BlazorServer));
        }
Ejemplo n.º 3
0
        public static string[] FindNpmTargetProjectFile(string[] projectFiles)
        {
            if (!projectFiles.Any())
            {
                return(Array.Empty <string>());
            }

            var assemblyNames = GetAssemblyNames(projectFiles);

            var projects = new List <string>();

            var project = FindProjectEndsWith(projectFiles, assemblyNames, ".Web.Host");

            if (project != null)
            {
                projects.Add(project);
            }

            project = FindProjectEndsWith(projectFiles, assemblyNames, ".Host", ".HttpApi.Host");
            if (project != null)
            {
                projects.Add(project);
            }

            if (projects.Any())
            {
                return(projects.ToArray());
            }

            project = FindProjectEndsWith(projectFiles, assemblyNames, ".Web");
            if (project != null)
            {
                projects.Add(project);
            }

            project = FindProjectEndsWith(projectFiles, assemblyNames, ".Blazor");
            if (project != null &&
                File.Exists(project) &&
                BlazorProjectTypeChecker.IsBlazorServerProject(project))
            {
                projects.Add(project);
            }

            return(projects.ToArray());
        }
Ejemplo n.º 4
0
        public static string FindNuGetTargetProjectFile(string[] projectFiles, NuGetPackageTarget target)
        {
            if (!projectFiles.Any())
            {
                return(null);
            }

            var assemblyNames = GetAssemblyNames(projectFiles);

            switch (target)
            {
            case NuGetPackageTarget.Web:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".Web"));

            case NuGetPackageTarget.IdentityServer:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".IdentityServer"));

            case NuGetPackageTarget.EntityFrameworkCore:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".EntityFrameworkCore"));

            case NuGetPackageTarget.MongoDB:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".MongoDB"));

            case NuGetPackageTarget.Application:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".Application") ??
                       FindProjectEndsWith(projectFiles, assemblyNames, ".Web"));

            case NuGetPackageTarget.ApplicationContracts:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".Application.Contracts"));

            case NuGetPackageTarget.Domain:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".Domain") ??
                       FindProjectEndsWith(projectFiles, assemblyNames, ".Application") ??
                       FindProjectEndsWith(projectFiles, assemblyNames, ".Web"));

            case NuGetPackageTarget.DomainShared:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".Domain.Shared"));

            case NuGetPackageTarget.HttpApi:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".HttpApi"));

            case NuGetPackageTarget.HttpApiClient:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".HttpApi.Client"));

            case NuGetPackageTarget.SignalR:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".SignalR") ??
                       FindProjectEndsWith(projectFiles, assemblyNames, ".Web") ??
                       FindProjectEndsWith(projectFiles, assemblyNames, ".HttpApi.Host"));

            case NuGetPackageTarget.Blazor:
                return(FindProjectEndsWith(projectFiles, assemblyNames, ".Blazor"));

            case NuGetPackageTarget.BlazorWebAssembly:
                var BlazorWebAssemblyTargetProject = FindProjectEndsWith(projectFiles, assemblyNames, ".Blazor");
                return(BlazorWebAssemblyTargetProject != null &&
                       !BlazorProjectTypeChecker.IsBlazorServerProject(BlazorWebAssemblyTargetProject)
                        ? BlazorWebAssemblyTargetProject
                        : null);

            case NuGetPackageTarget.BlazorServer:
                var BlazorServerTargetProject = FindProjectEndsWith(projectFiles, assemblyNames, ".Blazor");
                return(BlazorServerTargetProject != null &&
                       BlazorProjectTypeChecker.IsBlazorServerProject(BlazorServerTargetProject)
                        ? BlazorServerTargetProject
                        : null);

            default:
                return(null);
            }
        }