Skip to content

Tutorial 02 02 Creating a Basic Solution

Steve Ives edited this page Jul 8, 2020 · 12 revisions

Harmony Core Logo

Creating a Basic Solution

Using the harmonycore template is a quick way to create a basic development environment for a custom Harmony Core service that you can easily customize to meet your exact needs.

VIDEO: Creating a Basic Solution

Creating the New Solution

In the following steps, you will create a new development solution from the harmonycore template. The template provides the overall solution and project infrastructure is needed to create a custom Harmony Core service and has all of the project and Nuget package references that you might need already in place, but the regen batch file is in a pristine state, and the solution does not contain any pre-generated code. When using this template you are responsible for specifying the data structures and features that your service will have.

To use the template to create a new solution you use a command similar to this:

dotnet new harmonycore [-o <folderName>] [-n <solutionName>]

The optional -o <folderName> allows you to create a new subfolder for the solution, by default the solution will be created in the current folder. The name of the new solution will be the same as the name of the containing folder, but you can override it by specifying the -n <solutionName> option to provide a custom name for the solution.

To create a new solution:

  1. Open a Windows command prompt and move to the location where you would like the solution to be created.

  2. Create a new solution with the following command:

    dotnet new harmonycore -o MyApi
    

You should see various messages scroll by as the solution is created, like this:

The template "Harmony Core Starter Solution" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on MyApi\MyApi.sln...
  Restore completed in 458.49 ms for D:\MyApi\Services.Isolated\Services.Isolated.synproj.
  Restore completed in 458.49 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.
  Restore completed in 458.49 ms for D:\MyApi\Services.Host\Services.Host.synproj.
  Restore completed in 458.48 ms for D:\MyApi\Services\Services.synproj.
  Restore completed in 458.49 ms for D:\MyApi\Services.Models\Services.Models.synproj.

Restore succeeded.
Running 'dotnet restore' on MyApi\Repository/Repository.synproj...
  Nothing to do. None of the projects specified contain packages to restore.

Restore succeeded.
Running 'dotnet restore' on MyApi\Services/Services.synproj...
  Restore completed in 32.96 ms for D:\MyApi\Services.Isolated\Services.Isolated.synproj.
  Restore completed in 32.99 ms for D:\MyApi\Services\Services.synproj.
  Restore completed in 32.94 ms for D:\MyApi\Services.Models\Services.Models.synproj.
  Restore completed in 32.93 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.

Restore succeeded.
Running 'dotnet restore' on MyApi\Services.Controllers/Services.Controllers.synproj...
  Restore completed in 29.27 ms for D:\MyApi\Services.Models\Services.Models.synproj.
  Restore completed in 29.24 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.

Restore succeeded.
Running 'dotnet restore' on MyApi\Services.Host/Services.Host.synproj...
  Restore completed in 28.72 ms for D:\MyApi\Services.Models\Services.Models.synproj.
  Restore completed in 28.72 ms for D:\MyApi\Services.Isolated\Services.Isolated.synproj.
  Restore completed in 28.74 ms for D:\MyApi\Services\Services.synproj.
  Restore completed in 28.72 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.
  Restore completed in 37.26 ms for D:\MyApi\Services.Host\Services.Host.synproj.

Restore succeeded.
Running 'dotnet restore' on MyApi\Services.Isolated/Services.Isolated.synproj...
  Restore completed in 27.17 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.
  Restore completed in 27.2 ms for D:\MyApi\Services.Isolated\Services.Isolated.synproj.
  Restore completed in 27.17 ms for D:\MyApi\Services.Models\Services.Models.synproj.

Restore succeeded.
Running 'dotnet restore' on MyApi\Services.Models/Services.Models.synproj...
  Restore completed in 25.96 ms for D:\MyApi\Services.Models\Services.Models.synproj.

Restore succeeded.

D:\>

Unlike when using the harmonydemo template, the code in the projects generated by the harmonycore template is not complete and is not in a buildable form until you have configured the environment, generated some code, and added that code to various projects. Typically you will proceed in Visual Studio from this point.

Opening the Solution in Visual Studio

Having used the dotnet command-line tool to create your new development solution you can now work in Visual Studio.

  1. Start Visual Studio 2019

  2. Use the Open a Project or Solution option to open the new solution.

  3. Go to Solution Explorer. If you can't see Explorer, select View -> Solution Explorer from the menu.

  4. If the contents of the Solution Explorer are expanded, start by clicking the Collapse All button.

You should see something like this:

Harmony Core Logo

Customizing the Service

In the previous steps, you have created a "shell" environment into which you can start adding various types of data-centric or code-centric RESTful Web Service endpoints. The direction that you take from this point will depend on your requirements, but to get a good basic understanding of how Harmony Core services are built and work, we recommend following a specific path through the remaining tutorials.


Next topic: Enabling OData Support


Clone this wiki locally