Skip to content
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 #2189

Closed
AllanRegush opened this issue Dec 10, 2019 · 7 comments
Closed

Comments

@AllanRegush
Copy link

Steps to reproduce

dotnet new console and dotnet new

Expected behavior

Creates a new console app / lists help for dotnet new

Actual Behavior

Getting ready...
Object reference not set to an instance of an object.
   at Microsoft.TemplateEngine.Edge.Settings.SettingsLoader.Save(TemplateCache cacheToSave)
   at Microsoft.TemplateEngine.Edge.Settings.SettingsLoader.Save()
   at Microsoft.TemplateEngine.Cli.Installer.InstallPackages(IEnumerable`1 installationRequests, IList`1 nuGetSources, Boolean debugAllowDevInstall)
   at Microsoft.TemplateEngine.Cli.Installer.InstallPackages(IEnumerable`1 installationRequests)
   at Microsoft.DotNet.Tools.New.NewCommandShim.FirstRun(IEngineEnvironmentSettings environmentSettings, IInstaller installer)
   at Microsoft.TemplateEngine.Cli.New3Command.ConfigureEnvironment()
   at Microsoft.TemplateEngine.Cli.New3Command.Initialize()
   at Microsoft.TemplateEngine.Cli.New3Command.ExecuteAsync()
   at Microsoft.TemplateEngine.Cli.CommandParsing.NewCommandInputCli.<>c__DisplayClass19_0.<<OnExecute>b__0>d.MoveNext()

Environment Data

dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.100
 Commit:    cd82f021f4

Runtime Environment:
 OS Name:     opensuse-tumbleweed
 OS Version:  20191204
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.100/

Host (useful for support):
  Version: 3.1.0
  Commit:  157910edee

.NET Core SDKs installed:
  3.1.100 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

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

ie.

dotnet new --debug:reinit
rm -rf ~/.templateengine

Did not have this problem with dotnet sdk 2.0.

@AllanRegush
Copy link
Author

AllanRegush commented Dec 10, 2019

Update: I installed dotnet core 3.1 via snap - works fine. Could be something missing in the official opensuse package or due to tumbleweed having a different libicu package (libicu-suse65_1).

@mdx0111
Copy link

mdx0111 commented Dec 21, 2019

I'm having exact same problem on Fedora 31.
Running dotnet new throws the following:

Getting ready... Object reference not set to an instance of an object. at Microsoft.TemplateEngine.Edge.Settings.SettingsLoader.Save(TemplateCache cacheToSave) at Microsoft.TemplateEngine.Edge.Settings.SettingsLoader.Save() at Microsoft.TemplateEngine.Cli.Installer.InstallPackages(IEnumerable1 installationRequests, IList1 nuGetSources, Boolean debugAllowDevInstall) at Microsoft.TemplateEngine.Cli.Installer.InstallPackages(IEnumerable1 installationRequests)
at Microsoft.DotNet.Tools.New.NewCommandShim.FirstRun(IEngineEnvironmentSettings environmentSettings, IInstaller installer)
at Microsoft.TemplateEngine.Cli.New3Command.ConfigureEnvironment()
at Microsoft.TemplateEngine.Cli.New3Command.Initialize()
at Microsoft.TemplateEngine.Cli.New3Command.ExecuteAsync()
at Microsoft.TemplateEngine.Cli.CommandParsing.NewCommandInputCli.<>c__DisplayClass19_0.<b__0>d.MoveNext()`

This is the output of my dotnet --info:

`.NET Core SDK (reflecting any global.json):
Version: 3.1.100
Commit: cd82f021f4

Runtime Environment:
OS Name: fedora
OS Version: 31
OS Platform: Linux
RID: fedora.31-x64
Base Path: /usr/share/dotnet/sdk/3.1.100/

Host (useful for support):
Version: 3.1.0
Commit: 157910edee

.NET Core SDKs installed:
3.1.100 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
`
Any help would be appreciated.

Thanks.

@mdx0111
Copy link

mdx0111 commented Dec 24, 2019

I fixed it by wiping the "/usr/share/dotnet/templates" and "~/.templateengine" folders. Then reinstalling dotnet core 3.1 and then running dotnet new --debug:reinit.

Everything works fine now.

@limup
Copy link

limup commented Jan 15, 2020

I fixed it by wiping the "/usr/share/dotnet/templates" and "~/.templateengine" folders. Then reinstalling dotnet core 3.1 and then running dotnet new --debug:reinit.

Everything works fine now.

Thanks!

@GeorgeGomez
Copy link

I fixed it by wiping the "/usr/share/dotnet/templates" and "~/.templateengine" folders. Then reinstalling dotnet core 3.1 and then running dotnet new --debug:reinit.

Everything works fine now.

sweet!

@tanero
Copy link

tanero commented Mar 15, 2020

I have recieved same error today while installing dotnet 3.1 on centos7. First try was, i've removed all versions by calling yum remove dotnet* and install dotnet 3.1 but no success. (same error.)

Second, uninstalled dotnet 3.1 and deleted remaining files with folder, /usr/share/dotnet. In this time, server were clean and installed dotnet 3.1 again.

Voila, everything working as usual.

@rescobarm
Copy link

rescobarm commented Nov 26, 2020

Tenía el mismo problema con net5.0. Borré "/usr/share/dotnet/templates" como dice JorgeGomez y listo.
Pero ahora me sale el siguiente error: The framework 'Microsoft.AspNetCore.App', version '5.0.0' was not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants