Notes a on a step by step .NET standard based stack of applications with a central core
Posted by jpluimers on 2020/10/14
The idea is to have a stack of things that can be later put into multiple micro-service pillars.
Helpful: enable “Track Active Item in Solution Explorer”:
- Start with an empty repository; add an
origin
- Add .gitignore / .gitattributes appropriate for C#, for instance from github.com/Microsoft/vswhere,
git commit
it, and push it withgit push -u origin master
. - Add a blank solution using Creating a blank Visual Studio solution without a directory, and sln Format Version numbers and EmptyVisualStudioSolution
- Open the solution
- Add an “ASP.NET Core Web Application”
- Choose “API” in the list of ASP.NET templates, without Authentication or Docker support (let’s keep the balance bit simple enough for now)
- Run with Ctrl-F5, then confirm the SSL development certificate, and install it:
--------------------------- Security Warning --------------------------- You are about to install a certificate from a certification authority (CA) claiming to represent: localhost Windows cannot validate that the certificate is actually from "localhost". You should confirm its origin by contacting "localhost". The following number will assist you in this process: Thumbprint (sha1): 09EA054F 14D5D4CE 6B22C5F1 3E7EBDB5 F7583116 Warning: If you install this root certificate, Windows will automatically trust any certificate issued by this CA. Installing a certificate with an unconfirmed thumbprint is a security risk. If you click "Yes" you acknowledge this risk. Do you want to install this certificate? --------------------------- Yes No ---------------------------
- Your browser now opens at a port for debugging:
https://localhost:<port>/api/values
, then tries to download the result asvalues.json
.
This is configured in
Properties\launchSettings.json
under"launchUrl": "api/values"
(for the browser URL) andControllers\ValuesController.cs
under// GET api/values
for the actual implementation. - a
a
a
IHostedService
Have any service related stuff implement IHostedService
, so it is easy to deploy it in all kinds of processes:
- console to test
- windows service
- ASP.NET Core service
- Linux host application
Background information at .NET: IHostedService « The Wiert Corner – irregular stream of stuff.
–jeroen
Related:
- “.NET Standard Library” “One library to rule them all” – Google Search
- Translate Google Translate English: .NET Standard – One API rules everyone
- .NET Standard – jedno API vládne všem – MSDN Blog CZ/SK
- [WayBack] Introducing .NET Standard | .NET Blog A first-hand look from the .NET engineering teams
- [WayBack] standard/versions.md at master · dotnet/standard · GitHub
- [WayBack] What is the difference between .NET Core and .NET Standard Class Library project types? – Stack Overflow
- In the latest version of Visual Studio (2017) you have at least four different templates for creating a Class Library [WayBack] .NET Standard and .NET Core – To .NET:
- Class Library (Universal Windows)
- Class Library (.NET Framework)
- Class Library (.NET Core)
- Class Library (.NET Standard)
- Based on part on [WayBack] Create a Web API with ASP.NET Core and Visual Studio | Microsoft Docs: Build a web API with ASP.NET Core MVC and Visual Studio on Windows
Leave a Reply