Пример #1
0
 public SolutionModuleAdder(
     IJsonSerializer jsonSerializer,
     ProjectNugetPackageAdder projectNugetPackageAdder,
     DbContextFileBuilderConfigureAdder dbContextFileBuilderConfigureAdder,
     EfCoreMigrationAdder efCoreMigrationAdder,
     DerivedClassFinder derivedClassFinder,
     ProjectNpmPackageAdder projectNpmPackageAdder,
     NpmGlobalPackagesChecker npmGlobalPackagesChecker,
     IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
     SourceCodeDownloadService sourceCodeDownloadService,
     SolutionFileModifier solutionFileModifier,
     NugetPackageToLocalReferenceConverter nugetPackageToLocalReferenceConverter,
     VirtualFileProvider virtualFileProvider
     )
     : base(jsonSerializer,
            projectNugetPackageAdder,
            dbContextFileBuilderConfigureAdder,
            efCoreMigrationAdder,
            derivedClassFinder,
            projectNpmPackageAdder,
            npmGlobalPackagesChecker,
            remoteServiceExceptionHandler,
            sourceCodeDownloadService,
            solutionFileModifier,
            nugetPackageToLocalReferenceConverter)
 {
     VirtualFileProvider = virtualFileProvider;
 }
Пример #2
0
    private async Task AddNugetAndNpmReferences(ModuleWithMastersInfo module, string[] projectFiles,
                                                bool useDotnetCliToInstall)
    {
        var webPackagesWillBeAddedToBlazorServerProject = SouldWebPackagesBeAddedToBlazorServerProject(module, projectFiles);

        foreach (var nugetPackage in module.NugetPackages)
        {
            var nugetTarget =
                await IsProjectTiered(projectFiles) && nugetPackage.TieredTarget != NuGetPackageTarget.Undefined
                    ? nugetPackage.TieredTarget
                    : nugetPackage.Target;

            if (webPackagesWillBeAddedToBlazorServerProject && nugetTarget == NuGetPackageTarget.Web)
            {
                nugetTarget = NuGetPackageTarget.BlazorServer;
            }

            var targetProjectFile = ProjectFinder.FindNuGetTargetProjectFile(projectFiles, nugetTarget);
            if (targetProjectFile == null)
            {
                Logger.LogDebug($"Target project is not available for this NuGet package '{nugetPackage.Name}'");
                continue;
            }

            await ProjectNugetPackageAdder.AddAsync(null, targetProjectFile, nugetPackage, null, useDotnetCliToInstall);
        }

        var mvcNpmPackages = module.NpmPackages?.Where(p => p.ApplicationType.HasFlag(NpmApplicationType.Mvc))
                             .ToList();

        if (!mvcNpmPackages.IsNullOrEmpty())
        {
            var targetProjects = ProjectFinder.FindNpmTargetProjectFile(projectFiles);
            if (targetProjects.Any())
            {
                NpmGlobalPackagesChecker.Check();

                foreach (var targetProject in targetProjects)
                {
                    foreach (var npmPackage in mvcNpmPackages)
                    {
                        await ProjectNpmPackageAdder.AddMvcPackageAsync(Path.GetDirectoryName(targetProject), npmPackage);
                    }
                }
            }
            else
            {
                Logger.LogDebug("Target project is not available for NPM packages.");
            }
        }
    }
Пример #3
0
 public NpmPackagesUpdater(
     PackageJsonFileFinder packageJsonFileFinder,
     NpmGlobalPackagesChecker npmGlobalPackagesChecker,
     ICancellationTokenProvider cancellationTokenProvider,
     CliHttpClientFactory cliHttpClientFactory,
     ICmdHelper cmdHelper)
 {
     _packageJsonFileFinder    = packageJsonFileFinder;
     _npmGlobalPackagesChecker = npmGlobalPackagesChecker;
     CancellationTokenProvider = cancellationTokenProvider;
     CmdHelper             = cmdHelper;
     _cliHttpClientFactory = cliHttpClientFactory;
     Logger = NullLogger <NpmPackagesUpdater> .Instance;
 }
Пример #4
0
 public SolutionModuleAdder(
     IJsonSerializer jsonSerializer,
     ProjectNugetPackageAdder projectNugetPackageAdder,
     DbContextFileBuilderConfigureAdder dbContextFileBuilderConfigureAdder,
     EfCoreMigrationManager efCoreMigrationManager,
     DerivedClassFinder derivedClassFinder,
     ProjectNpmPackageAdder projectNpmPackageAdder,
     NpmGlobalPackagesChecker npmGlobalPackagesChecker,
     IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
     SourceCodeDownloadService sourceCodeDownloadService,
     SolutionFileModifier solutionFileModifier,
     NugetPackageToLocalReferenceConverter nugetPackageToLocalReferenceConverter,
     AngularSourceCodeAdder angularSourceCodeAdder,
     NewCommand newCommand,
     BundleCommand bundleCommand,
     CliHttpClientFactory cliHttpClientFactory,
     ICmdHelper cmdHelper,
     ILocalEventBus localEventBus)
 {
     JsonSerializer                        = jsonSerializer;
     ProjectNugetPackageAdder              = projectNugetPackageAdder;
     DbContextFileBuilderConfigureAdder    = dbContextFileBuilderConfigureAdder;
     EfCoreMigrationManager                = efCoreMigrationManager;
     DerivedClassFinder                    = derivedClassFinder;
     ProjectNpmPackageAdder                = projectNpmPackageAdder;
     NpmGlobalPackagesChecker              = npmGlobalPackagesChecker;
     RemoteServiceExceptionHandler         = remoteServiceExceptionHandler;
     SourceCodeDownloadService             = sourceCodeDownloadService;
     SolutionFileModifier                  = solutionFileModifier;
     NugetPackageToLocalReferenceConverter = nugetPackageToLocalReferenceConverter;
     AngularSourceCodeAdder                = angularSourceCodeAdder;
     NewCommand            = newCommand;
     BundleCommand         = bundleCommand;
     CmdHelper             = cmdHelper;
     LocalEventBus         = localEventBus;
     _cliHttpClientFactory = cliHttpClientFactory;
     Logger = NullLogger <SolutionModuleAdder> .Instance;
 }