Developer Docs

Running C#Bot

This article demonstrates the relevant procedure to configure database connection, install node modules, and run the C#Bot application.

This article assumes you have already setup a development environment for your specific operating system (C#Bot Setting Up Your Development Environment: Windows, C#Bot Setting Up Your Development Environment: Linux and C#Bot Setting Up Your Development Environment: Mac), the C#Bot Development Environment: Source Code lesson has been completed, and you have pulled your git repo to your machine.

For this guide, we assume Windows users are using Powershell and Linux/Mac users are using Bash as their shell.

A: First time setup

Database Connection Configuration

If you have followed the Setting Up Your Development Environment guide for your specific operating system (C#Bot Setting Up Your Development Environment: Windows, C#Bot Setting Up Your Development Environment: Linux and C#Bot Setting Up Your Development Environment: Mac) and chosen to use the default database configuration while installing PostgreSQL, you can skip these Database Connection Configuration steps.

You can configure your database credentials by changing the projects appsettings.xml, appsettings.Test.xml and appsettings.Development.xml files:

  1. Launch Powershell or Bash if Linux/Mac and navigate to the project directory.

     cd [path to application]/serverside/src
    
  2. Open the desired appsetting files and update the DbConnectionString username and password properties to match the username and password set during postgresSQL setup.

    DownloadNetCore2.2Image

    The port can be set by appending to the connection string Port=x; where x is the desired port number.

    See this Official Documentation from the npgsql website for more information on database connection string properties.

  3. Once you have customised your database connection string, you will need to turn on the protected region to prevent C#Bot from overriding your changes in the future.

    DownloadNetCore2.2Image

Database Update

Now that the database connection has been configured, the database itself needs to have all tables setup before first run.

  1. Navigate to the source folder on the server-side.

     cd [path to application]/serverside/src
    
  2. Create the migrations script

     dotnet ef migrations add [migration name]
    
  3. Execute the migrations

     dotnet ef database update
    

Installing Node Modules

Before the application can be run for the first time, the javascript dependancies need to be installed.

  1. Navigate to the clientside folder from your windows or Linux/Mac terminal of choice.

     cd [path to application]/clientside
    
  2. Use npm to install yarn package manager.

     npm install -g yarn
    
  3. Install node modules using yarn.

     yarn install
    

Creating a Solution file

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

  1. Navigate to the root directory of your project.

     cd [path to application]
    
  2. Create a new solution file.

     dotnet new sln
    
  3. 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/[name of your application].csproj
     dotnet sln add testtarget/Serverside/ServersideTests.csproj
     dotnet sln add testtarget/Selenium/SeleniumTests.csproj
     dotnet sln add testtarget/API/APITests.csproj
     dotnet sln add testtarget/TestDataLib/TestDataLib.csproj
    

B: Launching the development environment

C#Bot writes applications that can be launched with a single dotnet command. This means the server-side and client-side of the application are launched together since the client requires API’s with the server-side to operate.

  1. Firstly navigate to the serverside directory from your windows or Linux/Mac terminal of choice.

     cd [path to application]/serverside/src
    
  2. Run the following command to start the development server and clientside

     dotnet run
    
  3. Launch a browser of your choice i.e. firefox or chrome etc and navigate to http://localhost:5000. The development application should now be running.

C. Launching the production environment

  1. Firstly navigate to the serverside directory from your windows or Linux/Mac terminal of choice.

     cd [path to application]/serverside/src
    
  2. Enter the following command to publish the production .dll’s

     dotnet publish -c Release
    
  3. Navigate to the directory where the files have been published

     cd [path to application]/serverside/src/bin/Release/netcoreapp2.2/publish
    
  4. Run the production build:

     dotnet [application name].dll
    
  5. To run the application, launch your favorite browser i.e. chrome and navigate to http://localhost:5000. The production application should now be running.

D: Logging in to the application

When navigating to http://localhost:5000 you should be redirected to a login screen. You can use these credentials to log in, or you can create a new user account.

Username: super@example.com
Password: password

DownloadNetCore2.2Image

Was this article helpful?

Thanks for your feedback!

If you would like to tell us more, please click on the link below to send us a message with more details.

Tool:

Generate

Iterate

Bot:

C#Bot

SpringBot

On this page

New to Codebots?

We know our software can be complicated, so we are always happy to have a chat if you have any questions.