Contribute to Docs Contribute to Docs

Project Setup

This section shows how to setup and configure Piranha in your Application Startup and is intended for users who wants to create their application from scratch and not have this code generated by any of the available project templates.

If you want more information on how to create an ASP.NET Core web application from Visual Studio you can find this here.

Creating The Project

As we're going to setup the application from scratch we're going to start by creating an empty ASP.NET application using the standard project template provided with .NET Core. Start by creating a new empty directory with the name you want for your project. We will name the directory PiranhaWeb. After this is done position yourself in the directory and execute the following command in the terminal.

dotnet new web

After the project has been created, open the directory in your editor and open the .csproj project file. Before adding packages to your project you will need to create an ItemGroup section in your project file. After this is done your project file should look like this:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
  </ItemGroup>

</Project>

Choosing The Right Packages

Before setting up your application you need to know how your application environment will look and pick the packages that suits it. This includes choosing packages for Cache, Database and File Storage. In this example we will choose packages that are good for creating a simple local test application, namely:

  • In-memory Cache
  • SQLite Database provider
  • Local in-app File Storage

You can find a complete list of the different packages we provide here.

Core Packages

The following packages are needed for almost every type of application, no matter if it is a headless API-service or an integrated website. This includes the core library and tools for importing content types, data access, image manipulation and storage for uploaded media assets.

<ItemGroup>
  <PackageReference Include="Piranha" Version="10.0.0" />
  <PackageReference Include="Piranha.AttributeBuilder" Version="10.0.0" />
  <PackageReference Include="Piranha.Data.EF.SQLite" Version="10.0.0" />
  <PackageReference Include="Piranha.ImageSharp" Version="10.0.0" />
  <PackageReference Include="Piranha.Local.FileStorage" Version="10.0.0" />
</ItemGroup>

Web Packages

If you're building a classic integrated website you'll want to install the middleware components needed for routing and handling incoming requests to the application.

<ItemGroup>
  <PackageReference Include="Piranha.AspNetCore" Version="10.0.0" />
</ItemGroup>

Manager Packages

To add the management interface to your web application you need to add some kind of authentication package to authorize users, the manager package and one of the available HTML editors. Here we have choosen the package for the Tiny editor.

<ItemGroup>
  <PackageReference Include="Piranha.AspNetCore.Identity.SQLite" Version="10.0.0" />
  <PackageReference Include="Piranha.Manager" Version="10.0.0" />
  <PackageReference Include="Piranha.Manager.TinyMCE" Version="10.0.0" />
</ItemGroup>