Sample Projects - KevinDHeath/Samples GitHub Wiki

ASP.NET Core Web API

dotnet new webapi --output src\ASPNETCoreWebAPI --use-controllers --no-restore
dotnet sln add src\ASPNETCoreWebAPI\ASPNETCoreWebAPI.csproj

Enhancements:

  • Added a reference to the ClassLibrary project.
  • Added a MovieReview controller using the IMovieReview service.
  • Modified the WeatherForecast controller to use the IWeatherForecast service.

Blazor Identity

dotnet new blazor --output src\BlazorIdentity --auth Individual --no-restore

Enhancements:

  • ⚠️ Replaced the reference to Microsoft.EntityFrameworkCore.Tools with Microsoft.EntityFrameworkCore.Design to use the global tool. See the README file for information on building the database.
dotnet sln add src\BlazorIdentity\BlazorIdentity.csproj

Blazor Web App

dotnet new blazor --output src\BlazorWebApp --no-restore
dotnet sln add src\BlazorWebApp\BlazorWebApp.csproj

Enhancements:

  • Added a reference to the ClassLibrary project.
  • Added pages to use the IMovieReview service.
  • Modified the WeatherForecast pages to use the IWeatherForecast service.

Class Library

dotnet new classlib --output src\ClassLibrary --no-restore
dotnet sln add src\ClassLibrary\ClassLibrary.csproj

Enhancements:

  • Added central definition of data models, service interfaces and implementations.
  • Extended the WeatherForecast model to contain the season, determined by a new WeatherCalculator class.
  • Configured the project to produce a NuGet package.

Console App

dotnet new console --output src\ConsoleApp --no-restore --use-program-main
dotnet sln add src\ConsoleApp\ConsoleApp.csproj

Enhancements:

  • Added a reference to the ClassLibrary project.
  • Added some generic reflection functions.
  • Added some reflection utility functions.

WPF Application

dotnet new wpf --output src\WPFApplication --no-restore
dotnet sln add src\WPFApplication\WPFApplication.csproj

⚠️ Problem: "The name InitializeComponent does not exist in the current context (CS0103)" errors.
Note: these errors do not prevent the building or running of the application.

Enhancements:

  • Added references to the ClassLibrary and WPFCustomControlLib projects.
  • Added the counter custom control.
  • Added a list of WeatherForecast using the WeatherForecastEx service.
  • To associate theApp.xamland App.xaml.cs files as a single item the following group needed to be added to the WPFApplication.csproj file:
  <ItemGroup>
    <None Include="App.xaml"/>
  </ItemGroup>

❌ Can only add new WPF component files using Visual Studio.

WPF Custom Control Library

dotnet new wpfcustomcontrollib --output src\WPFCustomControlLib --no-restore
dotnet sln add src\WPFCustomControlLib\WPFCustomControlLib.csproj

Enhancements:

  • Added a counter custom control.
  • Added common resource styles that can be used by WPF applications.

xUnit Test Project

dotnet new xunit --output tests\xUnitTestProject --no-restore
dotnet sln add tests\xUnitTestProject\xUnitTestProject.csproj

Enhancements:

  • Added a reference to the ClassLibrary project.
  • Added 23 unit tests for the Extensions, Services and WeatherCalculator classes.
  • Added a .runsettings file and a RunTests.ps1 powershell script to produce the test results.
    Line coverage is 99% and branch coverage is 81%.

.NET Templates
dotnet new list
dotnet new [short-name] --help
Template Name Short Name Language Tags
API Controller apicontroller [C#] Web/ASP.NET
ASP.NET Core Empty web [C#],F# Web/Empty
ASP.NET Core gRPC Service grpc [C#] Web/gRPC/API/Service
✔️ ASP.NET Core Web API webapi [C#],F# Web/WebAPI/Web API/API/Service
ASP.NET Core Web API (native AOT) webapiaot [C#] Web/Web API/API/Service
ASP.NET Core Web App (Model-View-Controller) mvc [C#],F# Web/MVC
ASP.NET Core Web App (Razor Pages) webapp,razor [C#] Web/MVC/Razor Pages
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with React.js react [C#] Web/MVC/SPA
ASP.NET Core with React.js and Redux reactredux [C#] Web/MVC/SPA
Blazor Server App blazorserver [C#] Web/Blazor
Blazor Server App Empty blazorserver-empty [C#] Web/Blazor/Empty
✔️ Blazor Web App blazor [C#] Web/Blazor/WebAssembly
Blazor WebAssembly App Empty blazorwasm-empty [C#] Web/Blazor/WebAssembly/PWA/Empty
Blazor WebAssembly Standalone App blazorwasm [C#] Web/Blazor/WebAssembly/PWA
✔️ Class Library classlib [C#],F#,VB Common/Library
✔️ Console App console [C#],F#,VB Common/Console
dotnet gitignore file gitignore,.gitignore file Config
Dotnet local tool manifest file tool-manifest file Config
EditorConfig file editorconfig,.editorconfig file Config
global.json file globaljson,global.json file Config
MSBuild Directory.Build.props file buildprops file MSBuild/props
MSBuild Directory.Build.targets file buildtargets file MSBuild/props
MSTest Playwright Test Project mstest-playwright [C#] Test/MSTest/Playwright
MSTest Test Project mstest [C#],F#,VB Test/MSTest
MVC Controller mvccontroller [C#] Web/ASP.NET
MVC ViewImports viewimports [C#] Web/ASP.NET
MVC ViewStart viewstart [C#] Web/ASP.NET
NuGet Config nugetconfig,nuget.config file Config
NUnit 3 Test Item nunit-test [C#],F#,VB Test/NUnit
NUnit 3 Test Project nunit [C#],F#,VB Test/NUnit
NUnit Playwright Test Project nunit-playwright [C#] Test/NUnit/Playwright
Protocol Buffer File proto file Web/gRPC
Razor Class Library razorclasslib [C#] Web/Razor/Library/Razor Class Library
Razor Component razorcomponent [C#] Web/ASP.NET
Razor Page page [C#] Web/ASP.NET
Razor View view [C#] Web/ASP.NET
Solution File sln,solution file Solution
Web Config webconfig file Config
Windows Forms App winforms [C#],VB Common/WinForms
Windows Forms Class Library winformslib [C#],VB Common/WinForms
Windows Forms Control Library winformscontrollib [C#],VB Common/WinForms
Worker Service worker [C#],F# Common/Worker/Web
✔️ WPF Application wpf [C#],VB Common/WPF
WPF Class Library wpflib [C#],VB Common/WPF
✔️ WPF Custom Control Library wpfcustomcontrollib [C#],VB Common/WPF
WPF User Control Library wpfusercontrollib [C#],VB Common/WPF
✔️ xUnit Test Project xunit [C#],F#,VB Test/xUnit

Solution Configurations
Debug Release Testing
ASPNETCoreWebAPI ✔️ ✔️
BlazorWebApp ✔️ ✔️
ClassLibrary ✔️ ✔️ ✔️
ConsoleApp ✔️ ✔️
WPFApplication ✔️ ✔️
WPFCustomControlLib ✔️ ✔️
xUnitTestProject ✔️ ✔️

⚠️ **GitHub.com Fallback** ⚠️