How to avoid conflicts when testing your dotnet templates locally

 
 
  • Gérald Barré

When you author a dotnet template, you can use the dotnet install and dotnet new commands to create a new project based on your local template. However, dotnet install may conflict with a previous installation of the template published as a NuGet package. In this post, I describe how to avoid this conflict and how to test your template locally.

dotnet has a few hidden arguments that you can use to debug your template. The --debug:custom-hive argument allows you to specify a custom location for the template cache. This is useful when you want to test your template without affecting the global template cache.

Shell
dotnet new install /path/to/template --debug:custom-hive /temp/hive
dotnet new my_template --debug:custom-hive /temp/hive

You can create as many hives as needed to create isolated environments for testing your template.

Do you have a question or a suggestion about this post? Contact me!

Follow me:
Enjoy this blog?Buy Me A Coffee💖 Sponsor on GitHub