dotnet / templating

This repo contains the Template Engine which is used by dotnet new
https://docs.microsoft.com/dotnet/
MIT License
1.63k stars 369 forks source link

No template is installed when running `dotnet new --install` #3752

Closed LokiMidgard closed 3 years ago

LokiMidgard commented 3 years ago

I tried to install the UNO project template using dotnet new -i Uno.ProjectTemplates.Dotnet but nothing is installed. The Output:

Vorlagenname                                  Kurzname             Sprache     Tags
--------------------------------------------  -------------------  ----------  ----------------------
Console Application                           console              [C#],F#,VB  Common/Console
Class library                                 classlib             [C#],F#,VB  Common/Library
WPF Application                               wpf                  [C#],VB     Common/WPF
WPF Class library                             wpflib               [C#],VB     Common/WPF
WPF Custom Control Library                    wpfcustomcontrollib  [C#],VB     Common/WPF
WPF User Control Library                      wpfusercontrollib    [C#],VB     Common/WPF
Windows Forms App                             winforms             [C#],VB     Common/WinForms
Windows Forms Control Library                 winformscontrollib   [C#],VB     Common/WinForms
Windows Forms Class Library                   winformslib          [C#],VB     Common/WinForms
Worker Service                                worker               [C#],F#     Common/Worker/Web
MSTest Test Project                           mstest               [C#],F#,VB  Test/MSTest
NUnit 3 Test Project                          nunit                [C#],F#,VB  Test/NUnit
NUnit 3 Test Item                             nunit-test           [C#],F#,VB  Test/NUnit
xUnit Test Project                            xunit                [C#],F#,VB  Test/xUnit
Razor Component                               razorcomponent       [C#]        Web/ASP.NET
Razor Page                                    page                 [C#]        Web/ASP.NET
MVC ViewImports                               viewimports          [C#]        Web/ASP.NET
MVC ViewStart                                 viewstart            [C#]        Web/ASP.NET
Blazor Server App                             blazorserver         [C#]        Web/Blazor
Blazor WebAssembly App                        blazorwasm           [C#]        Web/Blazor/WebAssembly
ASP.NET Core Empty                            web                  [C#],F#     Web/Empty
ASP.NET Core Web App (Model-View-Controller)  mvc                  [C#],F#     Web/MVC
ASP.NET Core Web App                          webapp               [C#]        Web/MVC/Razor Pages
ASP.NET Core with Angular                     angular              [C#]        Web/MVC/SPA
ASP.NET Core with React.js                    react                [C#]        Web/MVC/SPA
ASP.NET Core with React.js and Redux          reactredux           [C#]        Web/MVC/SPA
Razor Class Library                           razorclasslib        [C#]        Web/Razor/Library
ASP.NET Core Web API                          webapi               [C#],F#     Web/WebAPI
ASP.NET Core gRPC Service                     grpc                 [C#]        Web/gRPC
dotnet gitignore file                         gitignore                        Config
global.json file                              globaljson                       Config
NuGet Config                                  nugetconfig                      Config
Dotnet local tool manifest file               tool-manifest                    Config
Web Config                                    webconfig                        Config
Solution File                                 sln                              Solution
Protocol Buffer File                          proto                            Web/gRPC

Examples:
    dotnet new mvc --auth Individual
    dotnet new blazorwasm
    dotnet new --help
    dotnet new nunit --help

I also tried dotnet new -i Microsoft.DotNet.Web.Spa.ProjectTemplates as shown in the docs but this also did not work.

dotnet --version shows 5.0.301

I'm not sure if that is related but I also installed 3.1.4.12 today. But I can't say if it worked before.

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

WeihanLi commented 3 years ago

Maybe it's because it had already been installed, you can try to install some other templates to see if it works, for example:

dotnet new -i Xunit.DependencyInjection.Template
LokiMidgard commented 3 years ago

@WeihanLi Today I'm on a different PC, but the PC where I have problems was setup recently and I'm as sure as I can be that I did not installed one of the templates I tested (before). Also if the templates would already be installed I should see them in the list and could create projects using new.

I just installed the uno templates on my current machine and it worked without problems.

But I can try to install Xunit when I get back to the problematic PC.

WeihanLi commented 3 years ago

Hi @LokiMidgard, I'm guessing maybe it's because the template you tried(Microsoft.DotNet.Web.Spa.ProjectTemplates) may already be included in the .NET SDK.

Glad to hear you installed other templates successfully.

LokiMidgard commented 3 years ago

@WeihanLi I could install on a different machine. On the problematic machine I was not able to install any (tested 2) templates. I will test more when I'm back (tomorrow or next week)

LokiMidgard commented 3 years ago

I tried to install Xunit.DependecyInjection.Template and it also does not work.

The output of dotnet --info

dotnet --info                                                                                                     
.NET SDK (gemäß "global.json"):
 Version:   5.0.301
 Commit:    ef17233f86

Laufzeitumgebung:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.301\

Host (useful for support):
  Version: 5.0.7
  Commit:  556582d964

.NET SDKs installed:
  3.1.412 [C:\Program Files\dotnet\sdk]
  5.0.301 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
vlada-shubina commented 3 years ago

@LokiMidgard Likely in case above the installation failed, however dotnet new has poor logging for install in 5.0, so the error is not shown.

We improved the install UX in .NET 6 (preview 4), if it works for you could you please install the latest .NET 6 preview and try again?

As for troubleshooting for 5.0.301, I may suggest to start with trying to perform dotnet restore manually as described here and see if it works.

If you can afford losing all previously installed templates for dotnet new, removing C:\Users\<username>\.templateengine\dotnetcli\5.0.301 folder content may also help (if settings got corrupted) but it will remove all previously installed templates.

LokiMidgard commented 3 years ago

@vlada-shubina

I have already installed .net 6 preview 6.0.100-preview.7.21379.14. I tried to install the template again and it worked now...

I don't know how to use the .net 5 version to install the template and I would prefre to not delete it, so I can't give you better information over error.

vlada-shubina commented 3 years ago

@LokiMidgard you can use global.json to specify SDK version to use. As the problem is solved, I'm closing the issue, please let me know in case of any further problems.