dotnet new Getting ready... Object reference not set to an instance of an object.
2021-02-17 11:45 Wizardlsw 阅读(213) 评论(0) 编辑 收藏 举报之前在CentOS上使用dotnet new
, dotnet new webapi -o testapi
[slin@izu templates]$ dotnet new webapi -o wannianapi
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, Boolean interactive)
at Microsoft.TemplateEngine.Cli.Installer.InstallPackages(IEnumerable`1 installationRequests, IList`1 nuGetSources, Boolean debugAllowDevInstall, Boolean interactive)
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()
Solution:
rm -rf /usr/share/dotnet/templates/
# 根据你已经安装的SDK, 重新安装templates
# https://www.nuget.org/packages?packagetype=template&sortby=relevance&q=Microsoft.DotNet&prerel=True
dotnet new --install Microsoft.DotNet.Web.ProjectTemplates.5.0::5.0.3
dotnet new --install Microsoft.DotNet.Common.ProjectTemplates.5.0::5.0.3
我这边暂时安装了两个:
- Microsoft.DotNet.Web.ProjectTemplates.5.0
- Microsoft.DotNet.Common.ProjectTemplates.5.0
之后再运行:`dotnet new` 看看就正常了
Reference
https://github.com/dotnet/templating/issues/2189
https://www.nuget.org/packages?packagetype=template&sortby=relevance&q=Microsoft.DotNet&prerel=True