question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't install custom template (Object reference not set to an instance of an object)

See original GitHub issue

I’ve created a new template but for some reason I’m getting an exception when trying to install it.

The source code to the template can be found in this PR: https://github.com/cake-build/frosting/pull/31/files

Environment

C:\Test> dotnet

Microsoft .NET Core Shared Framework Host

  Version  : 1.1.0
  Build    : 928f77c4bc3f49d892459992fb6e1d5542cb5e86
C:\Test> dotnet --version
1.0.1
C:\Test> dotnet --info
.NET Command Line Tools (1.0.1)

Product Information:
 Version:            1.0.1
 Commit SHA-1 hash:  005db40cd1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.1

Description

C:\Test> dotnet new

Template Instantiation Commands for .NET Core CLI.

Usage: dotnet new [arguments] [options]

Arguments:
  template  The template to instantiate.

Options:
  -l|--list         List templates containing the specified name.
  -lang|--language  Specifies the language of the template to create
  -n|--name         The name for the output being created. If no name is specified, the name of the current directory is used.
  -o|--output       Location to place the generated output.
  -h|--help         Displays help for this command.
  -all|--show-all   Shows all templates


Templates                       Short Name        Language      Tags
------------------------------------------------------------------------------
Cake Frosting Build Script      cakefrosting      [C#]          Cake/Frosting
Console Application             console           [C#], F#      Common/Console
Class library                   classlib          [C#], F#      Common/Library
Unit Test Project               mstest            [C#], F#      Test/MSTest
xUnit Test Project              xunit             [C#], F#      Test/xUnit
ASP.NET Core Empty              web               [C#]          Web/Empty
ASP.NET Core Web App            mvc               [C#], F#      Web/MVC
ASP.NET Core Web API            webapi            [C#]          Web/WebAPI
Solution File                   sln                             Solution

Examples:
    dotnet new mvc --auth None --framework netcoreapp1.1
    dotnet new classlib --framework netstandard1.4
    dotnet new --help

C:\Test> dotnet new cakefrosting

Object reference not set to an instance of an object.
   at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.SimpleConfigModel.ProduceOperationSetup(SpecialOperationConfigParams defaultMod
el, Boolean generateMacros, ICustomFileGlobModel customGlobModel)
   at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.SimpleConfigModel.Microsoft.TemplateEngine.Orchestrator.RunnableProjects.IRunna
bleProjectConfig.get_OperationConfig()
   at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.CreateAsync(IEngineEnvironmentSettings environmentSett
ings, ITemplate templateData, IParameterSet parameters, IComponentManager componentManager, String targetDirectory)
   at Microsoft.TemplateEngine.Edge.Template.TemplateCreator.<InstantiateAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.TemplateEngine.Cli.New3Command.<CreateTemplateAsync>d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.TemplateEngine.Cli.New3Command.<EnterSingularTemplateManipulationFlowAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.TemplateEngine.Cli.New3Command.<EnterTemplateManipulationFlowAsync>d__65.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.TemplateEngine.Cli.New3Command.<ExecuteAsync>d__66.MoveNext()

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mlorbetskecommented, Mar 9, 2017

My pleasure, let us know if there’s anything else we can do to help & be sure to list your template on the wiki so that it’s easy for others to find when you’re ready 😊

0reactions
seancpeterscommented, Mar 9, 2017

In the post_rtw branch, I’m able to install & create an instance of a template that does not have a sourceName. I attempted it with modifications to the existing C# console & mvc templates.

There are checks for the source name being null, and if so, doesn’t try to create entries in the renames dictionary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object Reference Not Set to an Instance of an Object
The following code throws an exception without the null coalescing. Adding “?? new List<string>()” prevents the “Object reference not set to an instance...
Read more >
What does "Object reference not set to an instance of an ...
I got same error when creating new view, after restarting the Visual Studio, it is gone. – Timur Turbil. Mar 7, 2022 at...
Read more >
How to solve error object reference not set to an instance of ...
I work on csharp i get error object reference not set to an instance of an object code give me error var Data...
Read more >
How to Fix Object Reference Not Set To An Instance of an Object
Error Message: Object Reference Not Set To An Instance of an Object Subscribe for uipath tutorial videos The error: " Object Reference Not...
Read more >
Object Reference Not set to an instance an object when try ...
Hi. I am developing the Item Template Visual Studio Extension to add our Forms in the Windows Form project with our components.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found