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

    • 7 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 XAF’s Solution Wizard and DevExpress Unified Component Installer). It is equivalent to Solution Wizard (.NET Framework) 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. Users with Universal subscription can find the package in their personal feed at https://nuget.devexpress.com.

    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. Obtain Your NuGet Feed Credentials

    You need to obtain your personal NuGet feed credentials to access the DevExpress.ExpressApp NuGet packages from your project. You can use NuGet feed URL or feed authorization key to manage DevExpress packages.

    1. Make sure your DevExpress.com account has access to XAF. This product line is included in the Universal subscription.

    2. Use your DevExpress credentials to log into nuget.devexpress.com.

    3. Obtain your NuGet feed credentials and copy them to the clipboard.

    4. Select DevExpress Online NuGet Feed as a NuGet Package Source.

      Alternatively, do it in the console. Run the following commands:

      # Register packages with an authorization key
      dotnet nuget add source https://nuget.devexpress.com/api/v3/index.json -n DXFeed -u DevExpress -p {your-feed-authorization-key}
      
      # Register packages with a feed URL
      dotnet nuget add source https://nuget.devexpress.com/{your-feed-authorization-key}/api/v3/index.json -n DXFeed
      

      For more information, refer to the following topic: Install NuGet Packages with Command Line Interface (CLI) Tools.

      An error may occur if the specified source is already in the source list. Run dotnet nuget list source to view all the configured sources and ensure the specified and nuget.org package sources are enabled. To enable them, use the dotnet nuget enable source command.

      You can also pass the NuGet feed as a -nf parameter when you create a project.

      dotnet new dx.xaf -n MyXafApp -p Blazor -nf https://nuget.devexpress.com/{your-feed-authorization-key}/api/v3/index.json
      

      The command creates a project and adds the nuget.config file with the DevExpress feed to the project folder.

    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 Solution Wizard 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.
    --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:

    -nf, --nuget-feed <nuget-feed>
    Specifies the NuGet Feed URL. Refer to https://nuget.devexpress.com/#feed-url and login to your account to obtain your personal feed URL.
    -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: Switch EF Core Connection from SQL Server to a Different Database Provider.

    -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 Win 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|None|OAuth2|Password|SSO|WinAD>
    Security options for the project. Multiple values are allowed.
    MiddleTier
    Adds a MiddleTier Web API Service project used by other platforms to access the database.
    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.
    None
    No security options enabled.
    -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
    KPI
    Adds the Windows Forms KPI Module.
    Notifications
    Adds the Notifications Module.
    Office
    Adds the Office Module (Rich Text Editor, Spreadsheet Editor, PDF Viewer) Module.
    PivotChart
    Adds the Windows Forms Pivot Chart Module.
    PivotGrid
    Adds the Windows Forms Pivot Grid Module.
    Reports
    Adds the Reports V2 Module.
    Scheduler
    Adds the Scheduler Module.
    ScriptRecorder
    Adds the Windows Forms Script Recorder 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.