Skip to content

Commit edd6153

Browse files
committed
naming, fixes to links and some additional info
1 parent 0db50b7 commit edd6153

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

docs/core/tutorials/cli-templates-create-template-package.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,28 @@ In this part of the series you'll learn how to:
3535

3636
A template package is one or more templates packed into a NuGet package. When you install or uninstall a template package, all templates contained in the package are added or removed, respectively.
3737

38-
Template packages are represented by a NuGet package (_.nupkg_) file. And, like any NuGet package, you can upload the template package to a NuGet feed. The `dotnet new install` command supports installing template packages from a NuGet package feed. Additionally, you can install a template package from a _.nupkg_ file directly.
38+
Template packages are represented by a NuGet package (_.nupkg_) file. And, like any NuGet package, you can upload the template package to a NuGet feed. The `dotnet new install` [command](../tools/dotnet-new-install.md) supports installing template packages from a NuGet package feed. Additionally, you can install a template package from a _.nupkg_ file directly.
3939

4040
Normally you use a C# project file to compile code and produce a binary. However, the project can also be used to generate a template package. By changing the settings of the _.csproj_, you can prevent it from compiling any code and instead include all the assets of your templates as resources. When this project is built, it produces a template package NuGet package.
4141

4242
The package you are going to generate will include the [item template](cli-templates-create-item-template.md) and [package template](cli-templates-create-project-template.md) previously created.
4343

44+
In order to create the template package, we will use the template for the template package provided by [Microsoft.TemplateEngine.Authoring.Templates](https://www.nuget.org/packages/Microsoft.TemplateEngine.Authoring.Templates).
4445
In your terminal, run the command:
4546

4647
```dotnetcli
4748
dotnet new install Microsoft.TemplateEngine.Authoring.Templates
4849
```
4950

50-
This [template package](https://github.com/dotnet/templating/tree/main/template_feed/Microsoft.TemplateEngine.Authoring.Templates) contains templates useful for template authoring.
51+
This [template package](https://www.nuget.org/packages/Microsoft.TemplateEngine.Authoring.Templates) contains templates useful for template authoring. Note: nuget.org should be available as NuGet feed inside the working directory to install this template package.
5152

5253
Navigate to the _working_ folder and run:
5354

5455
```dotnetcli
55-
dotnet new templatepack --name "templatepack"
56+
dotnet new templatepack --name "AdatumCorporation.Utility.Templates"
5657
```
5758

58-
The `--name` parameter sets the _.csproj_ filename to _templatepack.csproj_. You should see a result similar to the following output.
59+
The `--name` parameter sets the _.csproj_ filename to AdatumCorporation.Utility.Templates.csproj_. You should see a result similar to the following output.
5960

6061
```console
6162
The template "Template Package" was created successfully.
@@ -65,7 +66,7 @@ Description: Manual actions required
6566
Manual instructions: Open *.csproj in the editor and complete the package metadata configuration. Copy the templates to 'content' folder. Fill in README.md.
6667
```
6768

68-
Next, open the _templatepack.csproj_ file in a code editor and populate it according to the hints in the template:
69+
Next, open the _AdatumCorporation.Utility.Templates.csproj_ file in a code editor and populate it according to the hints in the template:
6970

7071
```xml
7172
<PropertyGroup>
@@ -81,15 +82,29 @@ Next, open the _templatepack.csproj_ file in a code editor and populate it accor
8182
</PropertyGroup>
8283
```
8384

84-
For getting more information about content of _templatepack.csproj_ file, navigate to [Pack a template into a NuGet package (nupkg file)](https://learn.microsoft.com/dotnet/core/tools/custom-templates#pack-a-template-into-a-nuget-package-nupkg-file).
85+
For getting more information about NuGet package metadata available in _AdatumCorporation.Utility.Templates.csproj_ file, navigate to [Pack a template into a NuGet package (nupkg file)](https://learn.microsoft.com/dotnet/core/tools/custom-templates#pack-a-template-into-a-nuget-package-nupkg-file).
86+
87+
By default, the created project file includes [template authoring MSBuild tasks](https://aka.ms/templating-authoring-tools).
88+
89+
```xml
90+
<PropertyGroup>
91+
<LocalizeTemplates>false</LocalizeTemplates>
92+
</PropertyGroup>
93+
94+
<ItemGroup>
95+
<PackageReference Include="Microsoft.TemplateEngine.Tasks" Version="*" PrivateAssets="all" IsImplicitlyDefined="true"/>
96+
</ItemGroup>
97+
```
98+
99+
Those MSBuild tasks provide template validation and [localization of the templates](https://aka.ms/templating-localization) capabilities. The localization is disabled by default, to enable creation of localization files, set `LocalizeTemplates` to `true`.
85100

86101
## Build and install
87102

88-
Save changes in _templatepack.csproj_ file. Before building the template package, verify that your folder structure is correct. Any custom template should be placed in the _content_ folder, in its own folder. The hierarchy should look similar to:
103+
Save changes in _AdatumCorporation.Utility.Templates.csproj_ file. Before building the template package, verify that your folder structure is correct. Any custom template should be placed in the _content_ folder, in its own folder. The hierarchy should look similar to:
89104

90105
```console
91106
working
92-
templatepack.csproj
107+
AdatumCorporation.Utility.Templates.csproj
93108
└───content
94109
├───extensions
95110
│ └───.template.config
@@ -109,9 +124,9 @@ C:\working> dotnet pack
109124
Microsoft (R) Build Engine version 16.8.0+126527ff1 for .NET
110125
Copyright (C) Microsoft Corporation. All rights reserved.
111126

112-
Restore completed in 123.86 ms for C:\working\templatepack.csproj.
127+
Restore completed in 123.86 ms for C:\working\AdatumCorporation.Utility.Templates.csproj.
113128

114-
templatepack -> C:\working\bin\Debug\net8.0\templatepack.dll
129+
AdatumCorporation.Utility.Templates -> C:\working\bin\Debug\net8.0\AdatumCorporation.Utility.Templates.dll
115130
Successfully created package 'C:\working\bin\Debug\AdatumCorporation.Utility.Templates.1.0.0.nupkg'.
116131
```
117132

0 commit comments

Comments
 (0)