×
Back to book

C# Local Environment Setup

This is an instructional on how to setup your environment for C#Bot development.

Prerequisites

  • These steps are to be carried out after a project has been created and cloned to your local environment.

Required Software

Mandatory Software

Recommended Software

Database

Depending on the project, an SQL Server or PostgreSQL database may be used. For either database, a user name of test and password of pass will be required. By default, a project on Codebots will use a Postgres database.

  • PostgreSQL
  • SQL Server
    • When configuring the server, ensure there is a SQL Server (not Windows User) user with the above credentials.
    • Ensure that TCP connections to the database are enabled

If the user for the database is not set up as specified then alter the connection string in serverside/src/appsettings.Development.xml. You do not need to create the database for the server, at this stage, it will be created later.

First time setup

It is important to note that if these steps are being done on Linux, you should not sudo these commands, or otherwise there shall be file ownership issues later.

  1. First the client-side needs to have its packages installed. To do so navigate to the clientside directory and run npm install -g yarn followed by yarn install.
  2. Navigate to serverside/src/ and run dotnet build
  3. Next an initial database migration must be created. Navigate to serverside/src and run dotnet ef migrations add InitialMigration.
  4. Next the migration needs to be applied to the database. In the serverside/src directory run dotnet ef database update. This step shall make the database and all of the tables.
  5. Now the server should be ready to run, in the serverside/src directory run dotnet run.
  6. You can now access the server by navigating to http://localhost:5000/ in your web browser of choice

Configuration

IDE

By default a sln file is not created, but this can be fixed from the dotnet command line.

  • In the root project directory run dotnet new sln
  • To add the dependent projects to the solution run the following commands in the same directory as the sln file
    • dotnet sln add serverside/src/[YOUR PROJECT NAME].csproj
    • dotnet sln add testtarget/Serverside/[YOUR PROJECT NAME]Test.csproj
    • dotnet sln add testtarget/Selenium/SeleniumTests.csproj

Now the sln file can be opened in an IDE such as Visual Studio or Rider.