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

dotnet new --uninstall --help no longer lists any items as being installed. #3041

Closed pranavkm closed 3 years ago

pranavkm commented 3 years ago

SDK: 6.0.100-preview.4.21214.10

List works but uninstall says no items are installed.

dotnet new --list
Template Name                                 Short Name           Language    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 Item                             nunit-test           [C#],F#,VB  Test/NUnit
NUnit 3 Test Project                          nunit                [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

D:\work> dotnet new --uninstall --help
Currently installed items:
(No Items)

With an older SDK, the uninstall command provides helpful instructions on how to uninstall specific packages:

dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.3.21202.5
 Commit:    aee38a6dd4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-preview.3.21202.5\

dotnet new --uninstall --help
Template Instantiation Commands for .NET Core CLI

Currently installed items:
  Microsoft.DotNet.Common.ItemTemplates
    Details:
      NuGetPackageId: Microsoft.DotNet.Common.ItemTemplates
      Version: 6.0.100-preview.3.21179.1
      Author: Microsoft
    Templates:
      dotnet gitignore file (gitignore)
      global.json file (globaljson)
      NuGet Config (nugetconfig)
      Solution File (sln)
      Dotnet local tool manifest file (tool-manifest)
      Web Config (webconfig)
    Uninstall Command:
      dotnet new -u Microsoft.DotNet.Common.ItemTemplates
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.

DavidKarlas commented 3 years ago

We changed how SDK templates are installed recently. Instead of copying them into each dotnet new version folder we leave them in place where SDK Installer puts them... And we don't allow users to uninstalling this templates anymore...

Plan we have for aspnetcore tests going forward is to provide --debug:disable-sdk-templates which will allow aspnet tests to start with 0 templates installed and then install local templates as needed, is this solution acceptable?

pranavkm commented 3 years ago

Plan we have for aspnetcore tests going forward is to provide --debug:disable-sdk-templates which will allow aspnet tests to start with 0 templates installed and then install local templates as needed, is this solution acceptable?

That should work - our tests spend a bunch of time uninstalling the templates (and then verifying the uninstall command worked), this seems like a better option.

Out of curiosity, if we're able to add debug specific options to these commands, is it possible to have a dotnet new mytemplatename --debug:nupkg-path:<path-to-nupkg> as an option which limits the templates to ones available in the package? It would avoid the extra step of having to ensure the template package is installed in the debug hive before we could install it.

DavidKarlas commented 3 years ago

What would be scenario? 1) dotnet new --install "/path/to/Aspnet.Web.v1.nupkg" --debug:disable-sdk-templates --debug:custom-hive "/path/to/hive" 1) dotnet new --install "/path/to/Aspnet.Web.v2.nupkg" --debug:disable-sdk-templates --debug:custom-hive "/path/to/hive" 1) dotnet new --install "/path/to/Aspnet.Web.v3.nupkg" --debug:disable-sdk-templates --debug:custom-hive "/path/to/hive" 1) dotnet new aspnetTemplate --debug:nupkg-path "/path/to/Aspnet.Web.v2.nupkg" --debug:disable-sdk-templates --debug:custom-hive "/path/to/hive"

And this would result in aspnetTemplate to be used from "/path/to/Aspnet.Web.v2.nupkg" regardless of Precedence or did you mean something else?

Would it help if we provided new command like dotnet new --uninstall --show-package aspnetTemplate that would print out "/path/to/Aspnet.Web.v2.nupkg"?

pranavkm commented 3 years ago

Something along the lines of the last one:

dotnet new aspnetTemplate --debug:nupkg-path "/path/to/Aspnet.Web.v2.nupkg" -o <somedir>

and the engine essentially ignores specifically looks for templates in the nupkg, ignoring any installed templates and precedence rules. It would also help some of our development testing, since it means we could pack the templates and have it be created without going thru the extra steps of installing / clearing the template cache etc.

DavidKarlas commented 3 years ago

Oh now I understand, so you want to skip install step completely, makes sense

pranavkm commented 3 years ago

The uninstall step 😄. But yes, it would be super convenient to point to a nupkg and say please install a template from this archive.

DavidKarlas commented 3 years ago

I believe that since adding --debug:disable-sdk-templates option it is possible for aspnet team to write performant integrations tests, hence closing this issue.