Sample Projects - KevinDHeath/Samples GitHub Wiki
dotnet new webapi --output src\ASPNETCoreWebAPI --use-controllers --no-restore
dotnet sln add src\ASPNETCoreWebAPI\ASPNETCoreWebAPI.csprojEnhancements:
- Added a reference to the
ClassLibraryproject. - Added a
MovieReviewcontroller using theIMovieReviewservice. - Modified the
WeatherForecastcontroller to use theIWeatherForecastservice.
dotnet new blazor --output src\BlazorIdentity --auth Individual --no-restoreEnhancements:
⚠️ Replaced the reference toMicrosoft.EntityFrameworkCore.ToolswithMicrosoft.EntityFrameworkCore.Designto use the global tool. See the README file for information on building the database.
dotnet sln add src\BlazorIdentity\BlazorIdentity.csprojdotnet new blazor --output src\BlazorWebApp --no-restore
dotnet sln add src\BlazorWebApp\BlazorWebApp.csprojEnhancements:
- Added a reference to the
ClassLibraryproject. - Added pages to use the
IMovieReviewservice. - Modified the
WeatherForecastpages to use theIWeatherForecastservice.
dotnet new classlib --output src\ClassLibrary --no-restore
dotnet sln add src\ClassLibrary\ClassLibrary.csprojEnhancements:
- Added central definition of data models, service interfaces and implementations.
- Extended the
WeatherForecastmodel to contain the season, determined by a newWeatherCalculatorclass. - Configured the project to produce a NuGet package.
dotnet new console --output src\ConsoleApp --no-restore --use-program-main
dotnet sln add src\ConsoleApp\ConsoleApp.csprojEnhancements:
- Added a reference to the
ClassLibraryproject. - Added some generic reflection functions.
- Added some reflection utility functions.
dotnet new wpf --output src\WPFApplication --no-restore
dotnet sln add src\WPFApplication\WPFApplication.csproj
⚠️ Problem: "The nameInitializeComponentdoes 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
ClassLibraryandWPFCustomControlLibprojects. - Added the counter custom control.
- Added a list of
WeatherForecastusing theWeatherForecastExservice. - To associate the
App.xamlandApp.xaml.csfiles as a single item the following group needed to be added to theWPFApplication.csprojfile:
<ItemGroup>
<None Include="App.xaml"/>
</ItemGroup>❌ Can only add new WPF component files using Visual Studio.
dotnet new wpfcustomcontrollib --output src\WPFCustomControlLib --no-restore
dotnet sln add src\WPFCustomControlLib\WPFCustomControlLib.csprojEnhancements:
- Added a counter custom control.
- Added common resource styles that can be used by WPF applications.
dotnet new xunit --output tests\xUnitTestProject --no-restore
dotnet sln add tests\xUnitTestProject\xUnitTestProject.csprojEnhancements:
- Added a reference to the
ClassLibraryproject. - Added 23 unit tests for the Extensions, Services and WeatherCalculator classes.
- Added a
.runsettingsfile and aRunTests.ps1powershell 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 | ✔️ | ❌ | ✔️ |