How to avoid conflicts when testing your dotnet templates locally

 
 
  • Gérald Barré

When authoring a dotnet template, you can use dotnet install and dotnet new to create a new project from your local template. However, dotnet install can conflict with a previously published NuGet package version of the same template. This post covers how to avoid that conflict and test your template locally.

dotnet provides a few hidden arguments for debugging templates. The --debug:custom-hive argument lets you specify a custom location for the template cache, allowing you 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 set up isolated environments for testing your templates.

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

Follow me:
Enjoy this blog?