Skip to content

1. Setup development environment

Alexander Hansson edited this page Mar 25, 2023 · 16 revisions

To set up the development environment, there are two main configurations methods:

  1. Docker & Visual Studio (Recommended)
  2. Stand Alone (no Docker and you can choose any IDE you like, for example Visual Studio Code)

Docker & Visual Studio

  1. Install Docker Desktop

    1. You can get it for Windows and Mac here
  2. Install Visual Studio

    1. 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.
  3. Open the solution (the code) in Visual Studio

    1. Open Visual Studio and open the solution file Nexpo.sln.
  4. Make sure the docker-compose "project" is selected as the startup project

    1. If not already selected as the startup project, right click docker-compose in the Solution Explorer and select "Set as Startup Project".
  5. Run the backend

    1. A databse with automatically be created

Stand Alone

  1. Install Docker Desktop
    1. You can get it for Windows and Mac here
  2. Containerize the database, by running:
docker run -d --name nexpo_database -p 5432:5432 -e POSTGRES_USER=nexpo -e POSTGRES_PASSWORD=nexpo postgres:14
Click to Expand for additional information
1. Note: Docker commands require sudo on Linux.
2. 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.
3. 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.
<style> details { border: 1px solid #ccc; border-radius: 4px; padding: 4px; margin: 4px; }
    summary {
        cursor: pointer;
        font-weight: bold;

} </style>

  1. Install .NET SDK
    1. It is available here
  2. Run the backend
    1. Run the following command to run:
    dotnet run --project Nexpo
    
Click to Expand for additional information
To avoid having to specify the project every time, you can also:
1. Change directories to the `Nexpo` project folder.
2. run `dotnet run` (without the `--project Nexpo` flag)
<style> details { border: 1px solid #ccc; border-radius: 4px; padding: 4px; margin: 4px; }
    summary {
        cursor: pointer;
        font-weight: bold;

} </style>

How to visualize DBeaver
1. Run previous command for running database in docker without Docker Desktop.
2. Download DBeaver https://dbeaver.io/download/
3. Connect to open postgres connection with settings Postgresql and default 5432 default port. db_name, user, password as nexpo
<style> details { border: 1px solid #ccc; border-radius: 4px; padding: 4px; margin: 4px; }
    summary {
        cursor: pointer;
        font-weight: bold;

} </style>

Setup Test Environment

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
Clone this wiki locally