Open Closed

What is the recommended way to configure a solution to fully utilize ABP source code #8102


User avatar
0
cfd000 created
  • ABP Framework version: v8.3.1
  • UI Type: Blazor WASM
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC): yes

What is the recommended way to create a new solution and incorporate all ABP source code using the CLI? This should include the base framework as well as any module source required (both open source and PRO modules).

We have a license for ABP Commercial with includes full source code. Any time we have needed to make a temporary modification or fix to the source (could be a breaking change, an immediate need to reference an updated NuGet package with a security update, etc.), it is too time consuming and error prone to switch from packages to source, so we must build our production release from full source to begin with. We would like to use the CLI so that we can script it and reuse the code for each major release (create a new clean ABP solution, validate that it builds, then bring over our changes from the prior version).


6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    First, you need to download the ABP framework and all the module's source code.

    Then, use CLI to switch to the local reference.

    https://abp.io/docs/latest/cli#switch-to-local

    For example:

    • abp new Testapp
    • Clone ABP repo
    • Change branch to rel-8.3
    • run abp switch-to-local --paths "....ABP repo path"
    • Build solution

    You will also need to download the source code for all commercial modules

  • User Avatar
    0
    cfd000 created

    Please provide specifics. What are the CLI command that should be used?

    1. When I run the CLI command to get a list of modules, how do I tell which are PRO modules, and which are already part of the open source ? Under the 'old' CLI, they were separated, but under the new CLI they are not.
    2. What location do I use for the source of the PRO modules? Do I put them in a folder at the same level as the framework?
    3. When using the new CLI, how do I know what name to use for the download? Many of the modules cannot be downloaded without changing the name (such as removing '.ABP' from the name).
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can use abp suite to check and replace modules with source code

    What location do I use for the source of the PRO modules? Do I put them in a folder at the same level as the framework?

    you can put it anywhere you want. I recommend you put it in the modules folder.

    When using the new CLI, how do I know what name to use for the download? Many of the modules cannot be downloaded without changing the name (such as removing '.ABP' from the name)

    They should all work,or you can use suite to download module

  • User Avatar
    0
    cfd000 created
    1. I specifically requested a CLI method. I need to script this so that it is done exactly the same way each time we do a major upgrade, and so that each step is done in order and documented. This script is part of our source code.
    2. The 'new' CLI is broken. Run "abp list-modules" and tell me how to parse that output to know which modules to request source code for, and which are included in the open source framework.
    # Run the abp list-modules command and capture the output
    $moduleList = & abp list-modules
    
    # Parse the module names from the command output
    $moduleNames = $moduleList | ForEach-Object {
        if ($_ -match '^>\s(.+)') {
            $matches[1]
        }
    }
    
    # Iterate over each module name and run the abp get-source command
    foreach ($module in $moduleNames) {
        Write-Output "Getting source for module: $module"
        & abp get-source $module --output-folder $module
    }
    
    1. How do I know which modules are pre-installed in the new project created by the CLI, and which need to be added by running "ABP add-module"?
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I specifically requested a CLI method. I need to script this so that it is done exactly the same way each time we do a major upgrade, and so that each step is done in order and documented. This script is part of our source code.

    The 'new' CLI is broken. Run "abp list-modules" and tell me how to parse that output to know which modules to request source code for, and which are included in the open source framework.

    You can continue to use the old CLI, just try abp list-modules --include-pro-modules --old

    How do I know which modules are pre-installed in the new project created by the CLI, and which need to be added by running "ABP add-module"?

    Sorry, no documentation yet; here's how the suite checks if a module is installed.

    public async Task<List<SuiteModuleInfo>> GetModuleListFromProductionAsync(Guid solutionId)
    {
        var client = _cliHttpClientFactory.CreateClient();
    
        var url = $"https://abp.io/api/download/modules-by-organization/?OrganizationName=<Your OrganizationName>";
        
        using (var responseMessage = await client.GetAsync(url))
        {
            var value = await responseMessage.Content.ReadAsStringAsync();
            var modules = JsonConvert.DeserializeObject<List<SuiteModuleInfo>>(value);
            modules = FilterFreeModulesThatHasProVersion(modules);
            await SetIsInstalledAsync(solutionId, modules);
            .......
        }
    }
    
    private async Task SetIsInstalledAsync(Guid solutionId, List<SuiteModuleInfo> modules)
    {
        var moduleFileContents = await GetContentsOfModuleFilesInSolutionAsync(solutionId);
    
        foreach (var module in modules)
        {
            if (moduleFileContents.Any(c => c.Contains($"using {module.Namespace}")))
            {
                module.IsInstalled = true;
            }
            else if (module.Name == "Volo.Abp.LeptonXTheme.Pro" && moduleFileContents.Any(c => c.Contains("LeptonX"))) //namespaces are different for UI options
            {
                module.IsInstalled = true;
            }
        }
    }
    
    private async Task<List<string>> GetContentsOfModuleFilesInSolutionAsync(Guid solutionId)
    {
        var solution = await _solutionService.GetByIdAsync(solutionId);
    
        var modulePaths = Directory.GetFiles(solution.RootProjectDirectory, "*Module.cs", SearchOption.AllDirectories);
    
        var fileContents = new List<string>();
    
        foreach (var modulePath in modulePaths)
        {
            fileContents.Add(await File.ReadAllTextAsync(modulePath));
        }
    
        return fileContents;
    }
    
  • User Avatar
    0
    cfd000 created

    Why was this question closed? It was not answered.

    I am looking for the ABP Recommended way to create, compile, and run a new solution completely off of local source and done in a scripted, repeatable way. Going through the GUI is not an acceptable answer - there is too much room for error.

Made with ❤️ on ABP v9.1.0-preview. Updated on October 22, 2024, 09:35