New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dotnet new fails: Object reference not set to an instance of an object #657

Closed
livarcocc opened this Issue Apr 24, 2017 · 7 comments

Comments

Projects
None yet
4 participants
@livarcocc
Copy link
Member

livarcocc commented Apr 24, 2017

From @sbomer on April 24, 2017 16:23

Steps to reproduce

dotnet new console

Expected behavior

Creates a new console app

Actual behavior

Object reference not set to an instance of an object.

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.0-preview2-005840)

Product Information:
 Version:            2.0.0-preview2-005840
 Commit SHA-1 hash:  8f2fcef544

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /home/sven/.sven/sdk/2.0.0-preview2-005840/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0-preview1-002061-00
  Build    : 2b70ec9c3b014af0c2a5f45de0e5b73a1ae51c09

Copied from original issue: dotnet/cli#6395

@livarcocc

This comment has been minimized.

Copy link
Member Author

livarcocc commented Apr 24, 2017

From @omajid on April 24, 2017 16:44

Somewhat unrelated question: when the compiler errors out with Object reference not set to an instance of an object, is there any way to ask it to display more information? For example, the name of the object? From what file? If not, is this worth considering as a bug by itself?

@mlorbetske

This comment has been minimized.

Copy link
Member

mlorbetske commented Apr 24, 2017

@seancpeters can you investigate please?

@seancpeters

This comment has been minimized.

Copy link
Collaborator

seancpeters commented Apr 24, 2017

Hi @sbomer,
I'm currently unable to reproduce this on Ubuntu16.04. If I can get more information from you, perhaps I can see what's happening. I'd like to check 2 things initially:

  1. Can you copy-paste the output from running dotnet new with no args?
  2. The first run of dotnet new should have created this directory: ~/templateengine/dotnet/cli/v2.0.0-preview2-005840. Can you let me know what files are in there? (copy of ls -al output would be best, if you're comfortable sharing that).

It's possible your dotnet new metadata got corrupted. This can potentially be fixed by running the following:
dotnet new --debug:reinit
Running this, you should see usage help, and an empty template list at the end.

After that, the next time you run dotnet new, it will do some initial setup, and then your template list should have all the templates that ship with dotnet.

@sbomer

This comment has been minimized.

Copy link
Member

sbomer commented Apr 24, 2017

@seancpeters, thanks for taking a look!

I'm confirming that running with --debug:reinit, or wiping the ~/.templateengine directory fixes the issue. Thanks! :)

Here's the info you requested for the investigation:

  1. dotnet new output, after clearing my nuget cache. If I run it again the output is the same after "Template Instantiation Commands...".
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.

Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.

Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 278 ms
Expanding 100% 255 ms
Template Instantiation Commands for .NET Core CLI

Usage: new [options]

Options:
  -h, --help          Displays help for this command.
  -l, --list          Lists templates containing the specified name. If no name is specified, lists all templates.
  -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.
  -i, --install       Installs a source or a template pack.
  -u, --uninstall     Uninstalls a source or a template pack.
  --type              Shows a subset of the available templates. Valid values are "project", "item" or "other".
  --force             Forces content to be generated even if it would change existing files.
  -lang, --language   Specifies the language of the template to create.


Templates                 Short Name       Language      Tags          
-----------------------------------------------------------------------
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    
Nuget Config              nugetconfig                    Config        
Web Config                webconfig                      Config        
Solution File             sln                            Solution      


Examples:
    dotnet new mvc --auth None
    dotnet new mstest
    dotnet new --help
  1. v2.0.0-preview2-005840.tar.gz
sven@sven-ubuntu-16:~/.templateengine/dotnetcli/v2.0.0-preview2-005840$ ls -al
total 56
drwxrwxr-x  3 sven sven  4096 Apr 24 08:41 .
drwxrwxr-x 19 sven sven  4096 Apr 24 14:31 ..
-rw-rw-r--  1 sven sven 30215 Apr 24 14:28 en-US.templatecache.json
-rw-rw-r--  1 sven sven     0 Apr 24 08:41 .firstrun
drwxrwxr-x  2 sven sven  4096 Apr 24 08:41 packages
-rw-rw-r--  1 sven sven  7663 Apr 24 14:28 settings.json
-rw-rw-r--  1 sven sven    24 Apr 24 14:28 templatecache.json
sven@sven-ubuntu-16:~/.templateengine/dotnetcli/v2.0.0-preview2-005840$ ls -al packages/
total 8
drwxrwxr-x 2 sven sven 4096 Apr 24 08:41 .
drwxrwxr-x 3 sven sven 4096 Apr 24 08:41 ..
-rw-r--r-- 1 sven sven    0 Apr 24 08:41 microsoft.dotnet.common.itemtemplates.1.0.0-beta2-20170410-189.nupkg
-rw-r--r-- 1 sven sven    0 Apr 24 08:41 microsoft.dotnet.common.projecttemplates.2.0.1.0.0-beta2-20170410-189.nupkg
-rw-r--r-- 1 sven sven    0 Apr 24 08:41 microsoft.dotnet.test.projecttemplates.2.0.1.0.0-beta2-20170410-189.nupkg
-rw-r--r-- 1 sven sven    0 Apr 24 08:41 microsoft.dotnet.web.projecttemplates.2.0.1.0.0-beta2-20170410-189.nupkg
sven@sven-ubuntu-16:~/.templateengine/dotnetcli/v2.0.0-preview2-005840$ 

@seancpeters

This comment has been minimized.

Copy link
Collaborator

seancpeters commented Apr 25, 2017

@sbomer - just wanted to confirm that --debug:reinit or wiping the config directory did fix the problem you were having with dotnet new.

@sbomer

This comment has been minimized.

Copy link
Member

sbomer commented Apr 25, 2017

@seancpeters Yes, it did, thanks! :D

@seancpeters

This comment has been minimized.

Copy link
Collaborator

seancpeters commented Apr 25, 2017

Great! Please let us know if you run into a problem like this again (or any other problem).

@mlorbetske mlorbetske closed this Apr 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment