Skip to content

Setup development environment

KlausEnevoldsen-Abtion edited this page Sep 26, 2023 · 3 revisions

Requirements

You must have the following installed and available on your machine:

Configuration

Local overrides of configurations/secret must be done through Secret Manager

These projects have User Secrets:

  • EndToEnd.Tests: ConnectionStrings:DefaultConnection (see "LocalDB" section below)
  • Api.Standalone
  • Api.WithReact, Api.WithReact.Tests: ActiveDirectoryConfig:AppClientSecret (see "Azure Active Directory" section in the Wiki)

Database connection

The project comes with connection strings for a docker container specified in docker-compose.yml. Start the DB with docker-compose up, then no further setup is required.

LocalDB

If you are running Windows with a instance of MS LocalDb, you can avoid using Docker for development and for the end-to-end tests by running these commands.

In the "EndToEnd.Tests" project folder: dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=(localdb)\mssqllocaldb;Database=MUFFINET-TEST;Trusted_Connection=True;MultipleActiveResultSets=true"

In the "Api.WithReact" project folder: dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=(localdb)\mssqllocaldb;Database=MUFFINET;Trusted_Connection=True;MultipleActiveResultSets=true"

In the "Api.Standalone" project folder: dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=(localdb)\mssqllocaldb;Database=MUFFINET;Trusted_Connection=True;MultipleActiveResultSets=true"

Installing dependencies

If you don't have yarn, install it:

npm install -g yarn

Restore dotnet project:

dotnet restore

Database migrations

First install dotnet-ef (if you haven't already):

dotnet tool install --global dotnet-ef

Then run the migrations:

dotnet ef database update --project src/Api.WithReact

You might get an error because the dotnet tools directory is not in your path.

Using zsh or linux/mac, this can be fixed with:

echo 'export PATH="$PATH:$HOME/.dotnet/tools"' >> ~/.zshrc
source ~/.zshrc

Adapting the command to bash/fish etc. should be a matter of replacing .zshrc, with for instance .bashrc.

Day-to-day

  • Run the server: dotnet run --project src/Api.WithReact
  • Run backend tests: dotnet test
  • Run frontend tests: yarn test
  • Run lint: yarn link
  • Run prettier: yarn format