Is there a special method for uninstalling a folder-template dotnet new
project beyond what is described in the .NET Core docs?
dotnet new -u <FILE_SYSTEM_DIRECTORY>
After setting up a folder template for dotnet new
, I installed it (per docs).
dotnet new --install ./some-template-folder/
This successfully puts the template in place for use with dotnet new {shortName}
.
The template "Some Template Name" was created successfully.
Unfortunately, I cannot uninstall that template afterwards using the appropriate command (per docs)
dotnet new --uninstall ./some-template-folder/
Resulting in the following output instead.
Could not find something to uninstall called '.\some-template-folder\'.
If it helps, here is the folder's minimal template.json file contained in the folder's .template.config sub-folder.
{
"$schema": "http://json.schemastore.org/template",
"author": "Some Author",
"classifications": [ "Some", "Various", "Search Keywords" ],
"identity": "Some.Identity",
"shortName": "name-used-in-dotnetnew",
"name": "Some Template Name"
}
dotnet/templating#1226
This turned out to be an issue with the state of the templates specific to my machine. After doing a dotnet new --debug:reinit
to revert the templates to their freshly installed state, the issue went away.
While my issue was machine-specific, there were some elements unique to path uninstalls via dotnet new --uninstall <path>
that could also cause this issue.
While you can install from a relative path (e.g., dotnet new --install ./some-template
), you must uninstall from a fully qualified path.
dotnet new --uninstall C:\full\path\to\some-template
Additionally, when you do pass in a fully qualified path to --uninstall
, do not include the terminal slash that your command-line environment may auto-include when you tab complete the path.
dotnet new --uninstall C:\full\path\to\some-template #<-- no terminal \ here
While all of the below details are still currently accurate, they have now added a system for determining exactly what uninstall string is required. Run the uninstall command without any parameters to see a list of installed templates listed by the exact string required to uninstall them.
dotnet new --uninstall
And it will output a list like this, with short names for NuGet packages and full paths for locally installed templates.
Template Instantiation Commands for .NET Core CLI
Currently installed items:
Microsoft.DotNet.Common.ItemTemplates
...
dotnet-new-project-helper
C:\full\path\to\some-template
You could then uninstall that final template with the listed path.
dotnet new --uninstall C:\full\path\to\some-template
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With