Coree.Template.Project
0.3.8934.10433
dotnet new install Coree.Template.Project::0.3.8934.10433
Coree.Template.Project
Welcome to the Coree.Template.Project repository! This project offers a comprehensive suite of templates for Visual Studio and dotnet CLI, designed to streamline the creation of various .NET projects. From MSBuild tasks to class libraries and WPF applications, this repository serves as a one-stop resource for developers looking to enhance their .NET development workflow.
Preperation (Prerequirments)
Windows Setup
Normal install and download procedure.
- Download/Install dotnet SDK
- Download/Install Visual Studio Code
- Download/Install Powershell
- Download/Install git
User-Space Installation of .NET and PowerShell Core on Windows.
To install dotnet and powershell core from cmd in Windows:
- Open the Command Prompt.
- Execute:
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -channel 6.0"
to install the .NET 6.0 SDK. - Execute:
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -channel 7.0"
to install the .NET 7.0 SDK. - Execute:
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -channel 8.0"
to install the .NET 8.0 SDK. - Execute:
powershell -NoProfile -ExecutionPolicy Unrestricted -Command "& {[Environment]::SetEnvironmentVariable('DOTNET_ROOT', \"$env:localappdata\Microsoft\dotnet\", 'User')}"
to set the enviroment variables. - Execute:
powershell -NoProfile -ExecutionPolicy Unrestricted -Command "& {[Environment]::SetEnvironmentVariable('PATH', \"$($env:path);$env:localappdata\Microsoft\dotnet\", 'User')}"
to set the enviroment variables. - Execute:
SET "DOTNET_ROOT=%localappdata%\Microsoft\dotnet" & SET "PATH=%PATH%;%localappdata%\Microsoft\dotnet"
to set the current session enviroment variables. - Execute:
dotnet tool install --global Powershell --no-cache
WSL Setup
WSL (Windows Subsystem for Linux) enables running Linux environments on Windows. This section covers its setup, essential for cross-platform development.
To set up WSL on Windows:
- Open the Command Prompt or PowerShell as an administrator.
- Execute:
wsl --install --no-distribution
. - Restart your computer when prompted.
To install a wsl image e.g Ubuntu on Windows:
- Open the Command Prompt or PowerShell.
- Execute:
wsl --update
to update your wsl to the latest version. - Execute:
wsl --set-default-version 2
to set the WSL version to WSL2. - Execute:
wsl --list --online
to list all online availible wsl image versions. - Execute:
wsl --install Ubuntu-22.04 --web-download
to install a online version as webdownload in the case the store is blocked. - Enter your username. If you get an error use lowercase and numbers only.
- Enter your password.
- Confirm your password.
To uninstall a wsl image e.g Ubuntu on Windows:
- Open the Command Prompt or PowerShell.
- Execute:
wsl --list
to see a list of your local installed wsl images. - Execute:
wsl --unregister Ubuntu-22.04
to remove a installed wsl image.
Setting up .NET, PowerShell, and Visual Studio Code on Ubuntu
To install dotnet powershell and vscode:
- Open the wsl app in windows or type
wsl
inside a command prompt. - Execute:
sudo apt-get update && sudo apt-get -y upgrade
to upgrade the linux distrobution to the latest state. - Execute:
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -channel 6.0
to install the .NET 6.0 SDK. - Execute:
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -channel 7.0
to install the .NET 7.0 SDK. - Execute:
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -channel 8.0
to install the .NET 8.0 SDK. - Execute:
export DOTNET_ROOT=$HOME/.dotnet ; export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools ; echo 'export DOTNET_ROOT=$HOME/.dotnet' >> $HOME/.bashrc && echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' >> $HOME/.bashrc
to add the dotnet root and path to the enviroment and shell startup. - Execute:
dotnet tool install --global PowerShell
if you want to use Powershell Core. - Execute:
sudo wget --content-disposition -O code.deb https://go.microsoft.com/fwlink/?LinkID=760868 && sudo apt install -y ./code.deb && rm -f ./code.deb
to install Visual Studio code. - Execute:
export DONT_PROMPT_WSL_INSTALL=1 ; echo 'export DONT_PROMPT_WSL_INSTALL=1' >> $HOME/.bashrc ; mkdir -p "$HOME/source/repos" ; mkdir -p "$HOME/source/packages"
to get rid of the Visual Studio code prompt, and to create some default directories. - Optional: Start visual studio code, Execute:
code
- Optional: In the case visual studio code flickers shutdown wsl inside windows command prompt and start wsl again. Execute:
wsl --shutdown & wsl export DONT_PROMPT_WSL_INSTALL=1 ; code
To uninstall dotnet powershell and vscode:
- Open the wsl app in windows or type
wsl
inside a command prompt. - Execute:
sudo apt-get remove -y code
to uninstall Visual Studio Code. - Execute:
dotnet tool uninstall --global PowerShell
to uninstall Powershell. - Manual: Remove entries $HOME/.bashrc and delete the .dotnet folder.
Install/Uninstall the templates
The commands below demonstrate how to install or uninstall the templates, primarily designed for .NET with Visual Studio 2022 compatibility in mind. Remember, template definitions might include specific limitations like conditional settings (true/false).
dotnet new install Coree.Template.Project
dotnet new uninstall Coree.Template.Project
The package contains the following templates:
Hint:
For testing packages created using these templates, consider setting up a local NuGet test repository. If you're looking to utilize locally built packages, simply establish a NuGet file repository.
In the packages dir PackageSpecs.props
you can add <LocalPackagesDir>$(userprofile)\source\packages</LocalPackagesDir>
Then add a local package source.
Linux/WSL (Sample useage):
mkdir -p "$HOME/source/packages" ; dotnet nuget add source "$HOME/source/packages" --name "SourcePackages"
Windows cmd (Sample useage):
mkdir "%userprofile%\source\packages" & dotnet nuget add source "%userprofile%\source\packages" --name "SourcePackages"
To remove the local source
dotnet nuget remove source "SourcePackages"
.NET MSBuild Task library
This template provides a foundation for building a .NET Standard compatible MSBuild task library, essential for tasks like build automation. It includes an MSTest project for testing the functionality you develop. The template is structured to support NuGet packaging and publishing, requiring an author's specification for these purposes.
General use:
dotnet new msbuildtasklib-coree --PackageAuthor Me
Modify the metadata for your NuGet package by accessing the PackageMetadata.props file located in the Package directory.
Linux/WSL (Sample useage):
dotnet new install Coree.Template.Project ; cd $HOME ; mkdir -p "source/repos/MyMSBuildTask" ; cd "source/repos/MyMSBuildTask" ; dotnet new msbuildtasklib-coree --PackageAuthor Me --name "MyMSBuildTask" --output "src" --force ; git init ; cd "src" ; dotnet test ; dotnet pack ; cd .. ; code -n . ; cd $HOME
Windows cmd (Sample useage):
dotnet new install Coree.Template.Project & cd /D %userprofile% & mkdir "source\repos\MyMSBuildTask" & cd "source\repos\MyMSBuildTask" & dotnet new msbuildtasklib-coree --PackageAuthor Me --name "MyMSBuildTask" --output "src" --force & git init & cd "src" & dotnet test & dotnet pack & cd.. & code -n . & cd /D %userprofile%
Enhance the TestScript.msbuild in the MSTest project to test your integration.
.NET Class library
This template provides a foundation for building a .NET compatible library. It includes an MSTest project for testing the functionality you develop. The template is structured to support NuGet packaging and publishing, requiring an author's specification for these purposes.
The test project is the primary source of functionality in this template. To ensure it meets your specific project needs, you should tailor and integrate it accordingly. I pre-configured most variables to minimize the effort required in delving deeply into each documentation, streamlining your setup process. If you keep the default setting, you can remove the test project without any impact.
Features:
- MSTest Project: Integrated for robust functionality testing.
- Coverlet Code Coverage: Measures code coverage to ensure comprehensive testing.
- ReportGenerator: Generates detailed reports on code coverage.
- BenchmarkDotNet: Included for performance benchmarking.
- Docfx: Facilitates documentation generation from source code and Markdown files.
- NLog: Implemented for basic logging, enhancing debugging and monitoring capabilities.
- Global.json & dotnet-tools.json: Specify SDK versions and local tool dependencies for a consistent development environment.
- Solution Items: Organized for better management of global solution-related files.
- Nuget-license overview: Uses the dotnet-project-licenses tool to document licenses used.
General use:
dotnet new classlib-coree --PackageAuthor Me
Modify the metadata for your NuGet package by accessing the PackageMetadata.props file located in the Package directory.
Linux/WSL (Sample useage):
dotnet new install Coree.Template.Project ; cd $HOME ; mkdir -p "source/repos/MyClassLib" ; cd "source/repos/MyClassLib" ; dotnet new classlib-coree --PackageAuthor Me --name "MyClassLib" --output "src" --force ; git init ; cd "src" ; dotnet test ; dotnet pack ; cd .. ; code -n . ; cd $HOME
Windows cmd (Sample useage):
dotnet new install Coree.Template.Project & cd /D %userprofile% & mkdir "source\repos\MyClassLib" & cd "source\repos\MyClassLib" & dotnet new classlib-coree --PackageAuthor Me --name "MyClassLib" --output "src" --force & git init & cd "src" & dotnet test & dotnet pack & cd.. & code -n . & cd /D %userprofile%
.NET Tool
This template provides a foundation for building a .NET commandline tool. The template is structured to support NuGet packaging and publishing, requiring an author's specification and ToolCommandName for these purposes. The final command will be the ToolCommandName. The Packagename is the Project and ToolCommandName
General use:
dotnet new nettool-coree --PackageAuthor Me --ToolCommandName helloworld
Modify the metadata for your NuGet package by accessing the PackageMetadata.props file located in the Package directory.
Linux/WSL (Sample useage):
dotnet new install Coree.Template.Project ; cd $HOME ; mkdir -p "source/repos/MyNetTool" ; cd "source/repos/MyNetTool" ; dotnet new nettool-coree --PackageAuthor Me --name "MyNetTool" --ToolCommandName helloworld --output "src" --force ; git init ; cd "src" ; dotnet test ; dotnet pack ; cd .. ; code -n . ; cd $HOME
Windows cmd (Sample useage):
dotnet new install Coree.Template.Project & cd /D %userprofile% & mkdir "source\repos\MyNetTool" & cd "source\repos\MyNetTool" & dotnet new nettool-coree --PackageAuthor Me --name "MyNetTool" --ToolCommandName helloworld --output "src" --force & git init & cd "src" & dotnet test & dotnet pack & cd.. & code -n . & cd /D %userprofile%
Assuming you've already copied your package to a NuGet source, whether it's local or remote, you can easily install it using the .NET Core CLI. Specifically, if you're created a prerelease version of a tool called MyNetTool.helloworld, you can install it globally on your machine with the following command.
dotnet tool install -g MyNetTool --prerelease
#REM OR use a temporary package location
dotnet tool install -g MyNetTool --prerelease --add-source "%userprofile%\MyNetTool\MyNetTool\bin\Pack"
Use:
C:\Users\MainUser>helloworld
Hello, World!
.NET Wpf (Windows only)
This template serves as a base for developing WPF applications, optimized primarily for .NET publishing as an executable. It includes five distinct configurations tailored for the dotnet publish process. Enhanced with basic visual improvements, the template utilizes the MaterialDesignThemes.MahApps package. You can tailor the App.xaml to your requirements, particularly by altering color keys like <Color x:Key="Primary200">#76bddf</Color>
, to suit your design preferences.
General use:
dotnet new wpfapp-coree --Author Me
Windows cmd (Sample useage):
cd /D %userprofile% & mkdir "MyWpfApp" & cd "MyWpfApp" & dotnet new wpfapp-coree --Author Me --force & dotnet publish & cd /D %userprofile%
Publish settings.
- Framework-required. (Purpose: Installer)
- Framework-required, Single-file. (Purpose: Copy smallest) ← DEFAULT
- Framework-included. (Purpose: Installer)
- Framework-included, Single-file. (Purpose: Copy large)
- Framework-included, Single-file, Compressed. (Purpose: Copy medium)
The Single-file selection will have the following settings.
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
Screenshots
.NET Project Template
Indeed, it may sound a bit perplexing at first – a project template for creating project templates. However, it's quite straightforward. For a project to generate templates, these must be situated within the packages/root/content folder. Additionally, a default class library is incorporated, complete with the provided names, to kickstart your project template creation. For more detailed guidance, refer to the educational section at the beginning of this readme.
General use:
dotnet new projecttemplate-coree --PackageAuthor "me" --SampleTemplateName "Testing template" --SampleTemplateShortName "test"
Linux/WSL (Sample useage):
dotnet new install Coree.Template.Project ; cd $HOME ; mkdir -p "source/repos/MyProjTemplate" ; cd "source/repos/MyProjTemplate" ; dotnet new projecttemplate-coree --PackageAuthor Me --name "MyProjTemplate" --SampleTemplateName "My Class library template" --SampleTemplateShortName "my template" --output "src" --force ; git init ; cd "src" ; dotnet pack ; cd .. ; code -n . ; cd $HOME
Windows cmd (Sample useage):
dotnet new install Coree.Template.Project & cd /D %userprofile% & mkdir "source\repos\MyProjTemplate" & cd "source\repos\MyProjTemplate" & dotnet new projecttemplate-coree --PackageAuthor Me --name "MyProjTemplate" --SampleTemplateName "My Class library template" --SampleTemplateShortName "my template" --output "src" --force & git init & cd "src" & dotnet pack & cd.. & code -n . & cd /D %userprofile%
Educational
For more information and resources for templating:
- MS Learn: Custom templates for dotnet new
- MS Learn: Create an item template
- MS Learn: Create a project template
- MS Learn: Create a template package
- Github: Templating Wiki
- Github: Net template samples
- Microsoft Project Repository .net winforms templates
For more information and resources for msbuild tasks:
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.3.8934.10433 | 874 | 6/17/2024 |
0.3.8906.20398 | 484 | 5/20/2024 |
0.2.8743.9548 | 4,450 | 12/9/2023 |
0.3.*.* (2024-05-20)
- CICD Setup
0.2.*.* (2024-01-01)
- Working templates and descriptions
0.1.*.* (2023-10-01)
- Basic project creation and templates