Setup

Prerequisites

Instructions

First create an empty database using Microsoft SQL Server Management Studio.

Now you can create your application either using Visual Studio or the Terminal.

Using Visual Studio

  1. Open Visual Studio and select “Create a new project”.
  2. Select the “KIT Application (Kontrolit)” project template and click “Next”.
  3. Enter the project name, e.g. “MyProject” and select the location you wish to save your project, e.g. “C:\Users\john-smith\Projects\my-project”. Make sure the checkbox for “Create in new folder” is NOT selected. Then click “Next”.
  4. Enter the database name, e.g. “KIT5-400000-MyApp” and click “Create”.
    1. If prompted that the solution has been modified outside the environment then click “Reload”.
  5. Now open the Terminal / Developer Powershell within Visual Studio and execute the following (make sure the path points to the root of the project):
npm install
gulp build

Optionally you can run the Gulp watch command from within the Task Runner Explorer or alternatively you can close and reopen the project for it to be started automatically. This will automatically build your assets as they change.

Using the Terminal

Make sure Gulp is installed globally by executing the following:

npm install --global gulp-cli

Make sure we have elevated permissions.

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

In Visual Studio make sure the order of the paths for web package management are correct. See https://stackoverflow.com/questions/37986800/node-sass-couldnt-find-a-binding-for-your-current-environment for more information.

Execute the following commands (replacing the repository, project and database names accordingly):

mkdir {repository-name}
cd {repository-name}
dotnet new kit -n {project-name} -d {database-name}
npm install
gulp build

Optionally you can also run the following command to automatically build your assets as they change:

gulp watch

Running the Application

The database schema is created the first time you run the application. Likewise it will automatically apply any changes if any of the dependencies are updated. This will be explained in greater detail in the module series.

Using Visual Studio

  1. Open the project in Visual Studio by executing the *.sln file.
  2. Set the “{project-name}.Web” project as the startup project by right clicking on it in the Solution Explorer.
  3. Now simply run the application which will automatically launch the browser.

Note: By default Visual Studio uses IIS Express as a web server. When you refresh the application it will automatically restart the the server if any *.cs files are changed. The server does not need to restart if you are changing views/assets. This means we do not need to automatically watch for changes (using dotnet watch).

Using the Terminal

Change the current working directory to the application's web project, for example:

cd src/{project-name}.Web

Now you just need to execute the following:

dotnet run

Note: You may need to start a new terminal if “gulp watch” is running.

Alternatively you can run the following which will automatically restart the server when *.cs files change:

dotnet watch run

Finally you can navigate to https://localhost:5001 to see your application.