Skip to main content
All docs
V26.1
  • .NET CLI Integration

    • 6 minutes to read

    You can use the .NET command line interface (CLI) to create XAF ASP.NET Core Blazor, Web API Service, and Windows Forms applications from the console (without using the DevExpress Template Kit and DevExpress Unified Component Installer). It is equivalent toTemplate Kit for .NET Core, but you can use it on any platform. This functionality is valuable for XAF developers who use Microsoft Visual Studio Code (VS Code) or JetBrains Rider in both Windows and non-Windows development environments (like Linux or MacOS).

    This topic describes how to:

    • Install the DevExpress XAF Templates to create an XAF project from CLI.
    • Register the NuGet feed to access the required NuGet packages.
    • Create an XAF application.

    Step 1. Install DevExpress XAF Templates

    Download the DevExpress.XAF.ProjectTemplates NuGet package and install it. The package is available to everyone at https://www.nuget.org.

    dotnet new install DevExpress.XAF.ProjectTemplates
    

    You can run the command below to see the list of available template options. These options are also described in detail in this article.

    dotnet new dx.xaf -h
    

    Step 2. Register Your License Key

    To obtain DevExpress NuGet packages from nuget.org you need to manually obtain and register your license key as described in the following help topic: Manual Registration: Obtain and Register Your Key.

    Step 3. Create an Application

    Run the following command to generate an XAF application:

    dotnet new dx.xaf -p Blazor Win -e2e -api Standalone -n DXApplication1
    

    The expected output project should be identical to a project generated by the Template Kit with the specified platforms and other default options.

    If you create a standalone Web API Service project, the cross-platform module project code is inserted into its appropriate place in the Web API Service project.

    Command Options

    Specify the following command line parameters to customize the project:

    Default dotnet new options:

    -n, --name <name>
    Solution name. If omitted, the command uses the name of the output directory.
    -o, --output <output>
    Specifies the output directory.
    --dry-run
    Displays a summary of what would happen if the given command line were run.
    --force
    Forces content to be generated even if it would change existing files.
    --framework
    Specifies the .NET version of the target XAF solution.
    --no-update-check
    Disables the check for the template package updates when instantiating a template.
    --project <project>
    The project that should be used for context evaluation.
    -lang, --language <C#>
    Specifies the template language to instantiate.
    --type <solution>
    Specifies the template type to instantiate.

    Template options:

    -db, --database <SqlServer|SqlAzure|...>

    Specifies the database provider for the solution.

    SqlServer (default)
    Adds a connection for the Microsoft SQL Server database.
    SqlAzure
    Adds a connection for the Microsoft SQL Azure database.
    PostgreSql
    Adds a connection for the PostgreSQL database.
    MySql
    Adds a connection for the MySQL database.
    Oracle
    Adds a connection for the Oracle database.
    Firebird
    Adds a connection for the Firebird database.
    Sqlite
    Adds a connection for the SQLite database.

    If you need to create an application with EF Core and a database not mentioned above, create an application with EF Core and SQL Server database provider and update it manually as described in the following topic: Specify EF Core Database Provider in XAF Application.

    -orm <EFCore|XPO>
    The target ORM for the solution.
    EFCore (Default)
    Adds the Entity Framework Core ORM.
    XPO
    Adds the XPO ORM.
    -dbu, --database-update <None|Auto|...>
    Configures whether ORM adds, modifies, and removes database objects if they do not match the data model structure.
    Auto (default)
    In Debug mode, automatically updates the database schema. Do not use with production databases or important data.
    None
    Disables database schema updates.
    Manual
    Enables manual ORM schema migrations via CLI. Refer to the following topic for more details: EF Core Migrations
    -p, --platform
    Adds a platform-specific project.
    Blazor
    Adds an ASP.NET Core Blazor XAF project.
    Win
    Adds a .NET Core Windows Forms XAF project.
    Default (Default)
    Adds an ASP.NET Core Blazor XAF project unless -api Standalone is specified. In this case, adds a Web API Service project.
    -e2e
    Adds a Functional Test project with EasyTest if true. The default value is false.
    -api <Integrated|None|Standalone>
    Adds a Web API Service project.
    Integrated
    Adds an integrated Web API Service to the ASP.NET Core Blazor project that is generated automatically if you did not specify it previously.
    Standalone
    Adds a Web API Service project to the solution. The base module code is placed in the suitable place in the project if you did not specify any platform-specific project.
    None (default)
    Does not add anything.
    -s, --security <MiddleTier|OAuth2|Password|SSO|WinAD>

    Security options for the project. Multiple values are allowed.

    MiddleTier

    Adds a Middle Tier Server project used by other platforms to access the database.

    If you select both the WinForms and Blazor platforms when creating the application and enable Middle Tier Server, the resulting application uses Middle Tier Server only in the WinForms project. However, if you select only the Blazor platform, the Blazor project uses Middle Tier Server.

    OAuth2
    Adds OAuth2 authentication providers (for example, GitHub).
    Password (default)
    Adds standard password authentication.
    SSO
    Enables Single Sign-On authentication. Automatically enables the OAuth2 option and disables the Password and WinAD options.
    WinAD
    Adds Windows Active Directory authentication.
    -mt, --multitenancy
    Enables Multi-Tenancy if true. The default value is false.
    -m, --modules <None|All|...>
    Adds XAF built-in modules to the project. Multiple values are allowed.
    None
    Does not add any modules.
    All
    Adds all modules available for your configuration.
    Default (default)
    Adds the Conditional Appearance and Validation Modules. For a standalone Web API Service project, adds the following modules: Audit Trail, Validation, File Attachments, and Reports V2.
    Audit
    Adds the ORM-specific Audit Trail Module.
    Charts
    Adds the Windows Forms Chart Module.
    Clone
    Adds the XPO Clone Object Module.
    Appearance
    Adds the Conditional Appearance Module.
    Dashboards
    Adds the Dashboards Module.
    Files
    Adds the File Attachments Module
    Notifications
    Adds the Notifications Module.
    Office
    Adds the Office Module (Rich Text Editor, Spreadsheet Editor, PDF Viewer) Module.
    PivotGrid
    Adds the Windows Forms Pivot Grid Module.
    Reports
    Adds the Reports V2 Module.
    Scheduler
    Adds the Scheduler Module.
    StateMachine
    Adds the State Machine Module.
    TreeList
    Adds the Windows Forms Tree List Editors Module.
    Validation
    Adds the Validation Module.
    Variants
    Adds the View Variants Module.

    Note

    The commands are case-insensitive.

    Step 4. Run the Application

    1. Navigate to the application folder, build the application, and run the project:

      cd DXApplication1.Blazor.Server
      dotnet run
      

      The command output should contain the application URL:

      Now listening on: http://localhost:5000
      
    2. Open your browser and navigate to the URL to see your application.

    3. When you try to log in, the application should display the following message: “The application cannot connect to the specified database because the database doesn’t exist, its version is older than that of the application, or its schema does not match the ORM data model structure.” Run the -updateDatabase command to update your database. For more information, refer to the following article: Production Database and Application Updates. You can also create a database manually.