Stack Name - ASP.NET Core

Synopsis

The is the base reusable implementation for an ASP.NET type tech stack.  ASP.NET is framework for building web apps and services with .NET and C#. The core features of the tech stack are:
  • ASP.NET Core 2.0 and .NET Framework v4x for full MVC support
  • Fully functional front-end using .cshtml with embedded JQuery and Bootstrap
  • nHibernate for model to table database mapping
The Harbormaster ASP.NET tech stack contains the necessary templates and macros to generate a fully functional project complete user interface, business objects, and a data access layer to read and write from the database of choice. This tech stack assumes installation and usage of Visual Studio.

Details

Author dev@harbormaster.ai
Access Public
Derived From .common.tech.stack .hibernate.tech.stack
Long Name ASP.NET Core
Short Name ASPNETCore
Language(s) C#, CSHTML, HTML, YAML, XML, Velocity Macros
Git Url https://github.com/Harbormaster-AI/techstacks/tree/main/ASP.NET%20Core
Example Project YAML https://github.com/Harbormaster-AI/cli/blob/main/samples/yamls/project.as.code/aspdotnet.project.as.code.yml

Options

Option Name description Type values
nuget
userName User name required to connect to artifact repo input default: 127.0.0.1
password Password required to connect to artifact repo input default: 11211
serverUrl ex: http://localhost:8081/artifactory input
repoKey Repository key input default: local-nuget-rep
licenseUrl URL to the license for the application input
projectUrl URL to this project input
iconUrl URL to an icon input
releaseNotes Release notes textarea
copyRight Copyright phrase input
tags meta tags used to help search for this app pkgCopyright phrase input

Contents

Along with what is supported by the parent tech stacks, the following are overridden and additional capabilities:
  • Build/Maven:
    • Uses Apache Maven to create a NuGet package and optionally store it to a supported artifact repository.
  • Build/Nuget:
    • Contains a template file as a Windows batch file to handle the actually interaction with the installed NuGet system.  Also contains the configuration to a connect to an artifact repo.
  • Business:
    • Velocity macros and templates used to create the business layer using C# while leveraging .NETs built-in MVC architecture.
  • Config:
    • Contains a .nuspec file.  It is an XML manifest that contains package metadata. This manifest is used both to build the package and to provide information to consumers. The manifest is always included in a package
  • Persistence:
    • Template files and Velocity macros used to create a Data Access layer to read write data using nHibernate.
  • Presentation:
    • Views and controllers as .CSHTML templates that handle form and list presentation, along with backend calls to the business delegates to read/write data.

Usage

Only recent have the majority of CI vendors made Windows an option.  Adding full vendor CI support for ASP.NET applications is now in progress.  Until then, use the instructions below for integration into Visual Studio to allow it to build, test, and run the resulting application.

To get started manually

Create a New Project

In Visual Studio, create an ASP.NET Core 2.0 project that the .NET Framework. (not the .NET Core). Be sure to name the project the same name as the application being generated

Option 1 – Using NuGet

The following steps require the use of NuGet to package and publish the generated application files.

Step 1 – Package Application with NuGet

Assuming nuget is installed, issue the following command within the root directory of the generated application files:

nuget sources Add -Name ____ -Source ____

For example, if using the JFrog Artifactory, the command looks like:

nuget sources Add -Name Artifactory -Source http:///artifactory/api/nuget/

Step 2 – NuGet API Key Authentication

NuGet tools require that sensitive operations are authenticated with the server using an apikey.

nuget setapikey : -Source ____

For example, if using the JFrog Artifactory, the command looks like:

nuget setapikey : -Source Artifactory

Step 3 – Package the Application

Next, NuGet requires the application be packaged:

nuget pack application.nuspec

This will create a file in the same directory with a .nupkg extension. This will push this file in the next step

Step 4 – Push the Application

Finally, the packaged application is ready to be pushed to a NuGet repository:

nuget push demo.0.0.1.nupkg -Source ____

For example, if using the JFrog Artifactory, the command looks like:

nuget push demo.0.0.1.nupkg -Source Artifactory

Import application

Use NuGet within Visual Studio to load the previously pushed application from the repository.

Option 2 – Not Using NuGet – copy generated files

Clone the project from GitHub overwriting into the Visual Studio project normally located at:

C:\Users\\source\repos\

Notice if Visual Studio auto-refreshes the project with the generated application files. If the project does not auto-refresh, force it to. If the files still do not appear, re-check they were copied into the correct directory.

Locate hibernate.cfg.xml

Within Visual Studio, locate the hibernate.cfg.xml file, right-click it and assign Build Action to Embedded Resource and Copy to Output to Copy Always.

Build

Build then run the project. Visual Studio will launch the app in the browser.