-
Notifications
You must be signed in to change notification settings - Fork 1
1. Setup development environment
It is pretty straight forward to set up the development environment. I have focused on two main configurations to keep the wiki brief:
- Docker & Visual Studio (Recommended)
- Stand Alone (no Docker and you can choose any IDE you like, for example Visual Studio Code)
The recommended setup is to use Visual Studio and Docker since that is the easiest and also the most consistent experience. It is worth noting that I won't be covering Linux in this guide at all but it should be pretty easy to get it up and running there as well, just follow the stand alone guide or use Docker Compose to run the application manually. The development is probably the most convenient on Windows but should work fine on Mac as well.
The basic steps are as follows:
- Install Docker Desktop
- Install Visual Studio
- Open the solution (the code) in Visual Studio
- Make sure the
docker-compose
"project" is selected as the startup project - Run
This is the easiest approach since the database is automatically created for you and you can get up and running in seconds if you have everything installed. The base prerequisite is that you have installed Docker on your system. You can get it for Windows and Mac here.
Install Visual Studio. Use the Community Edition if you don't have a license. During installation, select the "ASP.NET and web development" toolbox when given the choice to enable good support for Docker and the application.
Open Visual Studio and open the solution file Nexpo.sln
.
If not already selected as the startup project, right click docker-compose
in the Solution Explorer and select "Set as Startup Project".
Run the solution
For this to work, you need a database server running. There are two options for doing that, the first still using Docker to containerise the database but keeping it stand alone. The other is to install the normal binaries on your computer.
The default development database connection tries to access the database nexpo
on localhost:5432
using the credentials nexpo
:nexpo
. The nexpo
user of course needs the correct permissions on the database and if you change anything in the setup make sure to update the connection string as well.
The easiest way to set up an external database server is to use this docker command:
docker run -d --name nexpo_database -p 5432:5432 -e POSTGRES_USER=nexpo -e POSTGRES_PASSWORD=nexpo postgres:14
It will pull down the correct PostgreSQL server and set it up as we want it. Keep in mind though that no persistent volume is added to the container so don't do this in production.
If you want to set up the database manually without Docker then you probably know what you're doing so I wont cover that here.
Now that the database is up and running we also need the .NET SDK. Install it from here or your favourite package manager.
Open the code in your favourite editor and start hacking away at the code. When you want to run the code, open a terminal and change directories to the Nexpo
project folder. Then run the following command to run:
dotnet run
You could also run it from the root folder by appending --project Nexpo
but it is quite convenient to not have to append that if you want to create database migrations or do other things.
- Run previous command for running database in docker without Docker Desktop.
- Download DBeaver https://dbeaver.io/download/
- Connect to open postgres connection with settings Postgresql and default 5432 default port. db_name, user, password as nexpo
No matter the chosen setup method, it´s required to start an external database server before running the tests for them to pass. This is due to some tests utilizing black-box testing through testing against the controllers. It may take a while for the container to populate the tables with the example data, so if most controller-tests fail during the first run try to run them again.
NOTE: Running docker-compose in Visual Studio and then the tests do for some reason not work, even though it creates and starts the postgres container. Try instead to run the the shell command which creates a separate container for testing:
docker run -d --name nexpo_database -p 5432:5432 -e POSTGRES_USER=nexpo -e POSTGRES_PASSWORD=nexpo postgres:14