A template-package (NuGet) for creating solutions, with one or more projects, in dotnet / Visual Studio.
For the moment, because of an issue, the templates are not enabled in Visual Studio. See: Template.Source.json
dotnet new install HansKindberg-DotNet-Solution-Templates
or (if testing locally)
dotnet new install HansKindberg-DotNet-Solution-Templates --nuget-source "C:\Data\Projects\HansKindberg\DotNet-Solution-Templates\Source\Templates\bin\Debug"
or (if the package is in another nuget source)
dotnet new install HansKindberg-DotNet-Solution-Templates --nuget-source "https://nuget.example.org/v3/index.json"
dotnet new uninstall HansKindberg-DotNet-Solution-Templates
I am using Visual Studio 2022 - 17.8.3 when starting this project.
This project/solution was initially created with:
dotnet new templatepack -n "Templates"
To have "templatepack" you need to install Microsoft.TemplateEngine.Authoring.Templates:
dotnet new install Microsoft.TemplateEngine.Authoring.Templates
After creating the project with:
dotnet new templatepack -n "Templates"
I had to do some adjustments:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<GeneratePackageOnBuild>true</GeneratePackageOnBuild><!-- Added this row. -->
...
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking><!-- Added this row. -->
...
</PropertyGroup>
...
<ItemGroup>
...
<Content Include="content\**\*" Exclude="content\**\bin\**;content\**\obj\**">
<PackagePath>content</PackagePath><!-- Added this row. -->
</Content>
...
</ItemGroup>
...
</Project>
Got help by looking at:
How to install/uninstall during development.
cd to Source\Templates\bin\Debug.
Install:
dotnet new install HansKindberg-DotNet-Solution-Templates.0.0.1.nupkg
Uninstall:
dotnet new uninstall HansKindberg-DotNet-Solution-Templates
Install:
dotnet new install <PATH>
Uninstall:
dotnet new uninstall <PATH>
Where <PATH>
is the path to the folder containing .template.config.
cd to your project directory.
dotnet new hk-aspnet-razor-l --name hk-aspnet-razor-l
dotnet new hk-aspnet-razor-m --name hk-aspnet-razor-m
dotnet new hk-aspnet-razor-s --name hk-aspnet-razor-s
dotnet new hk-aspnet-razor-xl --name hk-aspnet-razor-xl --directTemplateProcessing false/true --kubernetesImageRegistry false/true
dotnet new hk-blazor-l --name hk-blazor-l
dotnet new hk-blazor-m --name hk-blazor-m
dotnet new hk-blazor-s --name hk-blazor-s
dotnet new hk-blazor-xl --name hk-blazor-xl --directTemplateProcessing false/true --kubernetesImageRegistry false/true
dotnet new hk-blazor-duende-l --name hk-blazor-duende-l
dotnet new hk-blazor-duende-m --name hk-blazor-duende-m
dotnet new hk-blazor-duende-s --name hk-blazor-duende-s
dotnet new hk-blazor-duende-xl --name hk-blazor-duende-xl --directTemplateProcessing false/true --kubernetesImageRegistry false/true
dotnet new hk-nuget-package-l --name hk.nuget.package.l
dotnet new hk-nuget-package-m --name hk.nuget.package.m
dotnet new hk-nuget-package-s --name hk.nuget.package.s
dotnet new hk-nuget-package-xl --name hk.nuget.package.xl
dotnet new hk-react-l --name hk-react-l
dotnet new hk-react-m --name hk-react-m
dotnet new hk-react-s --name hk-react-s
dotnet new hk-react-xl --name hk-react-xl --directTemplateProcessing false/true --kubernetesImageRegistry false/true
dotnet new hk-react-duende-l --name hk-react-duende-l
dotnet new hk-react-duende-m --name hk-react-duende-m
dotnet new hk-react-duende-s --name hk-react-duende-s
dotnet new hk-react-duende-xl --name hk-react-duende-xl --directTemplateProcessing false/true --kubernetesImageRegistry false/true
dotnet new hk-service-l --name hk-service-l
dotnet new hk-service-m --name hk-service-m
dotnet new hk-service-s --name hk-service-s
dotnet new hk-service-xl --name hk-service-xl --directTemplateProcessing false/true --kubernetesImageRegistry false/true
We have experienced problems when the solution-files included in the templates are not UTF-8-BOM encoded. If we make changes in the *.sln files we should verify that they are UTF-8-BOM encoded. If not, make them UTF-8-BOM encoded with Notepadd++ for example.
This seems to happen even if we have this in .editorconfig:
[*.{cshtml,sln}]
charset = utf-8-bom
There is a lot of "IO" in the integration-tests. Making the tests run sequential helps:
If we run the tests in parallel we often get failing tests.
His article/work led me the way to build "solution"-templates:
- CREATING DOTNET SOLUTION AND PROJECT TEMPLATES
- NuGet – Blazor.BFF.OpenIDConnect.Template
- GitHub – Blazor.BFF.OpenIDConnect.Template
- https://github.com/sayedihashimi/template-sample
- https://github.com/dotnet/templating
- Reference for template.json
- Reference for template.json - guids
- Tutorial: Create a template package - Create a template package project
- Visual Studio solution-structure for Docker-project with .editorconfig, Directory.Build.props and Directory.Build.targets
- Google: build visual studio template package
- Tutorial: Create a template package
- Tutorial: Create a project template
- https://github.com/dotnet/sdk/blob/main/template_feed/Microsoft.DotNet.Common.ProjectTemplates.9.0/Microsoft.DotNet.Common.ProjectTemplates.9.0.csproj
- Google: template.json tags type solution
- https://github.com/dotnet/templating/tree/main/dotnet-template-samples/content/05-multi-project
- Create dotnet new template with multiple projects
- How to create your own templates for dotnet new
- https://github.com/dotnet/dotnet-template-samples
- https://github.com/dotnet/dotnet-template-samples/tree/master/05-multi-project
- Create Solution Template - group of projects #611
- How does project system determine if the project is ASPNET or generic C#? #3079