Jump into the folder which same location with sln file. use the following command to install
dotnet new --install ./
You can run anywhere with the following command
dotnet new --uninstall
After the command executed, console should display all the template that you have been installed. And also display uninstall command that you can use.
follow the instruction from https://github.com/dotnet/templating/wiki/Runnable-Project-Templates
That says
The whole contents of the project folder, together with the .template.config\template.json file, needs to be placed into a folder named content.
Besides the content folder there needs to be a .nuspec file created. A packageTypes\packageType element with the value Template should be present in that file.
Both the content folder and the .nuspec file should reside in the same file system location.
so, we create a new .nuspec first. After created, it would be look like this
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>pako.template.webapi</id>
<version>1.0.0</version>
<authors>victor</authors>
<owners>victor</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<description>some description here</description>
<releaseNotes>init release.</releaseNotes>
<copyright>Copyright 2022</copyright>
<tags>template</tags>
<packageTypes>
<packageType name="template" />
</packageTypes>
</metadata>
</package>
Tips: you can run the following command to generator a default .nuspec file
nuget spec
Put the packageTypes
tag in .nuspec
is very important. That means the package is a project type package.
Finally, we can generator nupakg file by excute the following command
nuget pack
dotnet new --install PATH_OF_NUPKG
uninstall command
dotnet new --uninstall