How to work with FastReport Avalonia on .NET 8 in Visual Studio Code for Linux

We continue the series of articles about working with FastReport Avalonia in Visual Studio Code on various operating systems. In this article, we will analyze in detail how to run FastReport Avalonia on a Linux operating system using the Visual Studio Code IDE.

Avalonia UI is a .NET framework that is actively used for developing cross-platform user interfaces. With its universal API for application building, Avalonia supports all major platforms and runtime environments and has its unique interface. This ensures that your business solutions will look identical on every operating system.

FastReport Avalonia includes a powerful data processing engine, a familiar report designer, and a viewer for generated reports. Additionally, the new product supports all export formats of the built reports, such as PDF, Excel, MS Word, and many others.

The library is fully backward compatible with FastReport WPF, FastReport .NET, and FastReport Mono. It supports Avalonia UI, .NET 7, and .NET 8.

 

Preparatory stage

First, we need to install Visual Studio Code from the official website. Download the latest version of Visual Studio Code.

The next step is to install .NET 8 itself. To do this, you can go to the official Microsoft website and download the installer for Linux.

SDK .NET 8

We need to install Avalonia templates for further work. To do this, we need to open the console and enter the following command:

dotnet new install Avalonia.Templates

Next, open Visual Studio Code and configure it. Go to the Extensions tab. We need to install the following extensions: .NET Install Tool, Avalonia for Visual Studio Code, and C#.

.NET Install Toll

Avalonia for Visual Studio Code

C#

After installing the necessary extensions, we need to connect a private NuGet server to install the required FastReport packages. You can learn how to use a private NuGet server by following this link.

Once we have completed these steps, we can start creating the project.

 

Creating a project

To create an Avalonia project, open Visual Studio Code. Since we have installed the necessary templates and extensions, we should have a “Create Avalonia Project” button. Click on it. Then, select “Avalonia App” and specify the project name. Let’s name it “FastReportAvalonia.” Choose the directory where the project will be stored.

Created project with Avalonia templates

After creating the project, you may encounter an error when installing .NET 8 in the project. You can fix it by following these steps:
1) In the error window, click on “Configure Manager”;
2) Explicitly specify the path to .NET 8. For example: /usr/share/dotnet/dotnet.

In different distributions, the storage path of .NET 8 may vary, so please take this into account in your project.

Error when installing .NET

After that, we need to connect FastReport packages. To do this, open the .csproj file and add the following lines:

<PackageReference Include=”FastReport.Avalonia” Version=”2024.1.9” />
<PackageReference Include=”FastReport.Forms.Avalonia” Version=”2024.1.9” />

Our file should look something like this:

.csproj file

Next, go to the MainWindow.axaml file and add a button.

<Button Click =”ButtonClicked”> Start </Button>

The code in the file should look something like this:

MainWindow.axaml file

The next step is to write the logic for the button. To do this, open the MainWindow.axaml.cs file and create an event.

using FastReport;
…..
public void ButtonClicked(object source, RoutedEventArgs args)
{
 Report report = new Report();
 report.Load(“Отчет.frx);
 report.Design();
}

MainWindow.axaml.cs file

Now we can run our application. For debugging, we need to use .NET 5+. After launching, a window with a “Start” button will appear. Click on it, and the designer will launch.

Launched designer

We can also enable preview and view the report in Preview mode.

Report Preview

Thus, we were able to run FastReport Avalonia on Linux using Visual Studio Code. As you can see, there is nothing complicated in the setup and launch process. It is enough to install the SDK packages, and configure private NuGet packages, and then you can use FastReport Avalonia. If you have any questions, please contact our technical support at support@fast-report.com. Enjoy using FastReport Avalonia!

Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.
Trustpilot