Part of being in the #dotnet community is trying out other people’s ideas. One way people share those ideas is through project templates. Project templates allow you to set up a solution the author intended quickly. It also helps you reduce the amount of yak shaving that goes into starting a new project. However, with the convenience comes added frustrations. Unwanted templates can add a lot of noise to your new solution dialogs and CLI output.
In this short post, we’ll see how you can uninstall existing #dotnet templates and even how to update them.
Installing New Templates
If you search on NuGet for templates, you’ll find close to 1,600 available templates. That’s a lot of ideas ready for you to tap into to solve real-world problems. Typically, installing templates includes using the dotnet-cli. So first, let’s install the GraphQL library templates, which should help you jump-start your journey into the GraphQL world.
dotnet new --install HotChocolate.Templates::13.0.0-preview.24
Once installed, you should see the following console output.
dotnet new --install HotChocolate.Templates::13.0.0-preview.24 The following template packages will be installed: HotChocolate.Templates::13.0.0-preview.24 Success: HotChocolate.Templates::13.0.0-preview.24 installed the following templates: Template Name Short Name Language Tags ----------------------------- ----------- -------- ----------------- HotChocolate GraphQL Function graphql-azf [C#] Web/GraphQL/Azure HotChocolate GraphQL Server graphql [C#] Web/GraphQL
Nice! Looking at our new solution dialog in JetBrains Rider, you’ll also notice the templates appear on the left-hand menu.
Multiple templates come in a single package. Looking at the previous section, you’ll notice we installed two templates from a single package. To list the template packages we need to run the following command:
dotnet new --uninstall
The output should list all third-party packages installed in the current SDK. The dotnet-cli is also kind enough to list all the templates included in the package and the uninstall command.
dotnet new --uninstall Currently installed items: HotChocolate.Templates Version: 13.0.0-preview.24 Details: Author: Michael Staib NuGetSource: https://api.nuget.org/v3/index.json Templates: HotChocolate GraphQL Function (graphql-azf) C# HotChocolate GraphQL Server (graphql) C# Uninstall Command: dotnet new --uninstall HotChocolate.Templates
To remove the templates from our environment, we only need to run the uninstall command.
dotnet new --uninstall HotChocolate.Templates
Refreshing our new dialog screen in JetBrains Rider will show that the templates are no longer available.
It’s fun to try out different templates from the community, and it’s a great learning tool. However, you also want to ensure you have a relatively clean environment when developing apps. Using the dotnet-cli and the
dotnet new --uninstall command can help you identify and remove unwanted template packages. I hope you found this post enlightening, and thank you for reading this post.