Exemplo n.º 1
0
    public override async Task ExecuteAsync(ModuleInstallingContext context)
    {
        var _nugetSourceCodeStoreManager = context.ServiceProvider.GetRequiredService <INugetSourceCodeStore>();

        var zipFilePath = await _nugetSourceCodeStoreManager.GetCachedSourceCodeFilePathAsync(
            context.ModuleName,
            SourceCodeTypes.Module,
            context.Version);

        if (zipFilePath == null)
        {
            throw new AbpStudioException(message: $"Source code not found for {context.ModuleName} (v{context.Version})");
        }

        var targetFolder = context.GetTargetSourceCodeFolder();

        if (Directory.Exists(targetFolder))
        {
            return;
        }

        Directory.CreateDirectory(targetFolder);

        ZipFile.ExtractToDirectory(zipFilePath, targetFolder);
    }
Exemplo n.º 2
0
    public override async Task ExecuteAsync(ModuleInstallingContext context)
    {
        var efCoreProject = context.TargetModulePackages.FirstOrDefault(p => p.Role == PackageTypes.EntityFrameworkCore);

        if (efCoreProject == null)
        {
            return;
        }

        var efCoreProjectCsprojPath = efCoreProject.Path.RemovePostFix(PackageConsts.FileExtension) + ".csproj";

        var _derivedClassFinder = context.ServiceProvider.GetRequiredService <DerivedClassFinder>();
        var _dbContextFileBuilderConfigureAdder = context.ServiceProvider.GetRequiredService <DbContextFileBuilderConfigureAdder>();

        var dbContextFile = _derivedClassFinder.Find(efCoreProjectCsprojPath, "AbpDbContext").FirstOrDefault();

        if (dbContextFile == null)
        {
            return;
        }

        foreach (var declaration in context.EfCoreConfigurationMethodDeclarations)
        {
            _dbContextFileBuilderConfigureAdder.Add(dbContextFile, declaration.Namespace + ":" + declaration.MethodName);
        }
    }
Exemplo n.º 3
0
    private async Task AddReferenceAsync(
        ModuleInstallingContext context,
        PackageInfo targetPackage,
        PackageInfoWithAnalyze referencePackage)
    {
        var _csprojFileManager = context.ServiceProvider.GetRequiredService <ICsprojFileManager>();
        var csprojFilePath     = targetPackage.Path.RemovePostFix(PackageConsts.FileExtension) + ".csproj";

        if (context.WithSourceCode)
        {
            var referenceProjectPath = Directory.GetFiles(context.GetTargetSourceCodeFolder(),
                                                          $"*{referencePackage.Name}.csproj",
                                                          SearchOption.AllDirectories).FirstOrDefault();

            if (referenceProjectPath == null)
            {
                return;
            }

            await _csprojFileManager.AddProjectReferenceAsync(
                csprojFilePath,
                referenceProjectPath);
        }
        else
        {
            await _csprojFileManager.AddPackageReferenceAsync(
                csprojFilePath,
                referencePackage.Name,
                context.Version);
        }
    }
Exemplo n.º 4
0
    public async Task <ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context)
    {
        context.AddEfCoreConfigurationMethodDeclaration(
            new EfCoreConfigurationMethodDeclaration(
                "Volo.Abp.IdentityServer.EntityFrameworkCore",
                "ConfigureIdentityServer"
                )
            );

        return(GetBasePipeline(context));
    }
Exemplo n.º 5
0
    public async Task <ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context)
    {
        context.AddEfCoreConfigurationMethodDeclaration(
            new EfCoreConfigurationMethodDeclaration(
                "Volo.Abp.BlobStoring.Database.EntityFrameworkCore",
                "ConfigureBlobStoring"
                )
            );

        return(GetBasePipeline(context));
    }
Exemplo n.º 6
0
    public override async Task ExecuteAsync(ModuleInstallingContext context)
    {
        var _abpModuleFileManager = context.ServiceProvider.GetRequiredService <IAbpModuleFileManager>();

        foreach (var referencePackage in context.ReferenceModulePackages)
        {
            var targetPackages = GetTargetPackages(context.TargetModulePackages, referencePackage);

            foreach (var targetPackage in targetPackages)
            {
                await AddReferenceAsync(context, targetPackage, referencePackage);

                var targetAbpModulePath = FindAbpModuleFile(targetPackage.Path);

                await _abpModuleFileManager.AddDependency(targetAbpModulePath, FindAbpModuleName(referencePackage));
            }
        }
    }
Exemplo n.º 7
0
    public async override Task ExecuteAsync(ModuleInstallingContext context)
    {
        var moduleFolder        = Path.GetDirectoryName(context.TargetModule);
        var commonPropsFilePath = Path.Combine(moduleFolder, "common.props");

        if (!File.Exists(commonPropsFilePath))
        {
            return;
        }

        var _csprojFileManager = context.ServiceProvider.GetRequiredService <ICsprojFileManager>();

        var csProjFiles = Directory.GetFiles(context.GetTargetSourceCodeFolder(), "*.csproj", SearchOption.AllDirectories);

        foreach (var csProjFile in csProjFiles)
        {
            await _csprojFileManager.AddAssemblyVersionAsync(csProjFile, context.Version);

            await _csprojFileManager.AddCopyLocalLockFileAssembliesAsync(csProjFile);
        }
    }
Exemplo n.º 8
0
    protected ModuleInstallingPipeline GetBasePipeline(ModuleInstallingContext context)
    {
        var pipeline = new ModuleInstallingPipeline(context);

        if (context.WithSourceCode)
        {
            pipeline.Add(new SourceCodeDownloadStep());

            if (context.AddToSolutionFile)
            {
                pipeline.Add(new AddToSolutionFileStep());
            }
        }

        pipeline.Add(new PackageReferencingStep());

        if (context.EfCoreConfigurationMethodDeclarations.Any())
        {
            pipeline.Add(new AddEfCoreConfigurationMethodStep());
        }

        return(pipeline);
    }
Exemplo n.º 9
0
 public abstract Task ExecuteAsync(ModuleInstallingContext context);
Exemplo n.º 10
0
 public async Task <ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context)
 {
     return(GetBasePipeline(context));
 }
Exemplo n.º 11
0
 public ModuleInstallingPipeline(ModuleInstallingContext context)
 {
     Context = context;
     Steps   = new List <ModuleInstallingPipelineStep>();
 }
Exemplo n.º 12
0
    public override async Task ExecuteAsync(ModuleInstallingContext context)
    {
        var _solutionFileModuleAdder = context.ServiceProvider.GetRequiredService <ISolutionFileModuleAdder>();

        await _solutionFileModuleAdder.AddAsync(context.TargetModule, context.ModuleName);
    }