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

Question on dotnet uninstall #961

Closed
guardrex opened this issue Jun 16, 2017 · 16 comments
Closed

Question on dotnet uninstall #961

guardrex opened this issue Jun 16, 2017 · 16 comments

Comments

@guardrex
Copy link
Contributor

I think I have a misunderstanding on how -u|-uninstall works (or perhaps there's a list refresh that I'm missing for an uninstalled template).

For testing purposes I created a few file system test templates, such as this one for Giraffe4.Template/giraffe4 ...

{
  "identity": "Giraffe4.Template",
  "author": "guardrex",
  "classifications": [ "Web", "Giraffe", "blah" ],
  "name": "Giraffe Web App4",
  "tags": {
    "language": "F#"
  },
  "shortName": "giraffe4",
  "sourceName": "_AppName"
}

Install works fine ...

dotnet new -i c:\template4

However, uninstall doesn't want to remove the template. I've tried the following two commands ...

dotnet new -u Giraffe4.Template
dotnet new -u giraffe4

... but the template persists in the list ...

capture

dotnet --info:

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

Product Information:
 Version:            2.0.0-preview2-006349
 Commit SHA-1 hash:  30a0bc3028

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0-preview2-006349\

Microsoft .NET Core Shared Framework Host
  Version  : 2.0.0-preview2-25406-03
  Build    : baa69770c40ce13dcb1a8979b288be8cb23f9c7b
@seancpeters
Copy link
Contributor

Hi @guardrex,
Uninstall is currently driven by the location the template was installed from. Since giraffe4 was installed using:
dotnet new -i c:\template4
you'll be able to uninstall it using the same path:
dotnet new -u c:\template4

Please let us know if that works for you.

@guardrex
Copy link
Contributor Author

@seancpeters Ah! ..... the ONE thing I didn't try! lol .... Thanks much! I'm good, and I'll make sure the doc spells that out.

@guardrex
Copy link
Contributor Author

@seancpeters Just want to mention one quick thing in passing tho:

It seems awfully easy to have orphan template entries: If the folder containing the template is moved, deleted, or renamed, it orphans the template in the list without an easy way to uninstall/remove it. Apparently, one has to re-create the template folder (perhaps with just the .template.config\template.json file) in order to run the uninstall command. Perhaps the team might consider a few proposals? ....

  • If only the identity or short name is used and the .template.config\template.json can't be found: Delete that entry from the list.
  • If the identity or short name is used and the .template.config\template.json is found, only delete the template from the list and leave the artifacts on the system.
  • If the location is used and the .template.config\template.json can't be found: Delete that entry from the list.

If any of this makes sense to discuss, it might go better on a new issue, so let me know. Otherwise, feel free to close. I'm just tossing out some ideas/concerns on it.

@guardrex guardrex reopened this Jun 16, 2017
@guardrex
Copy link
Contributor Author

... and I've run into another little misunderstanding. I zipped a template into template7.zip. I was able to install it ok ...

dotnet new -i c:\template7.zip

... but when try to uninstall that one with ...

dotnet new -u c:\template7.zip

... it says ...

Could not find something to uninstall called 'c:\template7.zip'.

@guardrex
Copy link
Contributor Author

One more problem: After installing a template from a ZIP (template8.zip; giraffe8) and then trying to install it with ...

dotnet new giraffe8

... it fails with ...

capture

If you need any of this on new issues, let me know. Right now, I'm not sure if I'm still not making mistakes on my end of using the dotnet new command; or in this case, assuming that it will do something that it can't do.

@seancpeters
Copy link
Contributor

seancpeters commented Jun 16, 2017

While installing templates from .zip sources works, it's not a fully supported scenario. So there's not a real uninstall story for zip-installed templates at this time.

Dotnet new offers full support for installing directly from files, and from nupkg's. If you install from a nupkg, you can uninstall the templates from the nupkg by giving the nupkg name on the command line, e.g.:
dotnet new -u microsoft.dotnet.web.projecttemplates.2.0

Warning: Running that command will uninstall all of the web templates shipped with dotnet new (so you probably don't want to run that specific command).

Your suggestions for other delete scenarios are good, we've had numerous discussions about other uninstall scenarios, and may support some of them in the future. In general, finding out the issues you & other real-world users are running into is a great source for enhancement ideas. Definitely continue letting us know what issues you run into & additional functionality you'd like.

We can leave this all as one issue, it's not a problem.

@seancpeters
Copy link
Contributor

Your error with the giraffe8 template is peculiar. I'm not yet certain what would have caused it. If you can provide any additional information or steps taken, it might help me figure it out. If you want to reset your installation to its initial state, which will remove all custom installed templates, you can run:
dotnet new --debug:reinit
...and then the next time you run dotnet new, it will go through first-run initialization. But please note that the --debug:reinit flag is not a documented feature, and may change or be removed at any time.

@guardrex
Copy link
Contributor Author

guardrex commented Jun 16, 2017

Thanks for your help.

While installing templates from .zip sources works, it's not a fully supported scenario.

Ah, I see. I'll leave it out of the doc. I picked up on it from @sayedihashimi's blog post and the Wiki text.

btw- This is all for the work on dotnet/docs#2139. We're adding a ref doc for the custom templates. For a walk-through/tutorial, we're planning on pointing readers to @sayedihashimi's blog post. There might be (probably will be) a formal tutorial in the Core docs later.

I'll go with install/uninstall from the following:

  • File system
  • NuGet packages from a NuGet feed
  • NuGet package projects with a nupkg <- I have yet to investigate this approach.

--debug:reinit flag is not a documented feature, and may change or be removed at any time.

... so I'll leave that one out as well.

I won't be describing Zip-based templates, but here's how it went with my giraffe8 test ... I'm going to re-run the process from scratch using a new one: giraffe9, and I'll run this process from my Desktop:

  1. Setup the template.json of the test project:
    {
      "identity": "Giraffe9.Template",
      "author": "guardrex",
      "classifications": [ "Web", "Giraffe", "blah" ],
      "name": "Giraffe Web App9",
      "tags": {
        "language": "F#"
      },
      "shortName": "giraffe9",
      "sourceName": "_AppName"
    }
    
  2. Zip the template folder into template9.zip on the desktop.
  3. Install with dotnet new -i c:\users\XXXXXX\desktop\template9.zip
  4. Execute a dotnet new -l to confirm it was installed. It worked and giraffe9 is listed.
  5. Create a new folder on the desktop, test. In that folder, execute: dotnet new giraffe9 <--- then the error appears. It claims c:\template.json access is denied. I'm an admin ... but really ... that's not the right location for the json file anyway. It's still sitting in c:\users\XXXXXX\desktop\template9.zip.

@seancpeters
Copy link
Contributor

Thanks for the additional info. Unfortunately, I'm still unable to reproduce the issue. Could you provide the directory structure of this template (unzipped)? For example the C# 2.0 class library template looks like this:

templating\template_feed\Microsoft.DotNet.Common.ProjectTemplates.2.0\content>tree /F ClassLibrary-CSharp
Folder PATH listing
Volume serial number is 0000029A 6286:FDD1
C:\GITHUB\TEMPLATING\TEMPLATE_FEED\MICROSOFT.DOTNET.COMMON.PROJECTTEMPLATES.2.0\CONTENT\CLASSLIBRARY-CSHARP
│   Class1.cs
│   Company.ClassLibrary1.csproj
│
└───.template.config
        dotnetcli.host.json
        template.json

The error message about looking for template.json at the c:\ directory is most likely an issue with the error reporting, I think I see how that could report incorrectly. Once I can repro the main issue, the reason & fix for the incorrect error message will hopefully be obvious.

@guardrex
Copy link
Contributor Author

guardrex commented Jun 17, 2017

It's just the basic "Giraffe" template. The only thing I'm changing in it is the template.json file. The directory structure of the uncompressed version is ...

Program.fs
_AppName.fsproj
.template.config
      template.json
Models
      Message.fs  
Views
      Index.cshtml

I acquired it by grabbing the ZIP of the whole https://github.com/dustinmoris/Giraffe repo and then pulling out the template/content folder contents into my own template folder, which is template9 for my latest test.

and the template.json is ...

{
  "identity": "Giraffe9.Template",
  "author": "guardrex",
  "classifications": [ "Web", "Giraffe", "blah" ],
  "name": "Giraffe Web App9",
  "tags": {
    "language": "F#"
  },
  "shortName": "giraffe9",
  "sourceName": "_AppName"
}

@guardrex
Copy link
Contributor Author

@seancpeters I had to delete my last message, because I was still in the process of wrapping my brain around it: It turns out that one installs from a nupkg on disk (locally) (never from a nuspec) but then uninstalls by just providing the package name as you said earlier.

So if the user installs with ...

dotnet new -i C:\Users\<USER>\GarciaSoftware.ConsoleTemplate.CSharp.1.0.0.nupkg

they uninstall with ...

dotnet new -u GarciaSoftware.ConsoleTemplate.CSharp.1.0.0

Going back to an earlier post, I think it would be far simpler if uninstall was merely based on giving the shortName to the command ...

dotnet new -u garciaconsole

... and let the ✨ .NET magic ✨ figure out where/what to uninstall, even if it only meant delisting the template (i.e., when the template itself is no longer on disk or a template at nuget.org doesn't exist/can't be found).

I think that I have what I need to get the 1st draft of this topic out, which relies heavily on the Wiki and @sayedihashimi's blog post to cover the deeper/finer points. Is it ok if I ping you on the PR to take a 👀 look at it?

@seancpeters
Copy link
Contributor

@guardrex - definitely feel free to ping me on any PR's for this repo :)

@guardrex
Copy link
Contributor Author

@seancpeters Excellent, thanks. I'm giving it a final read before I add it to our 2.0 CLI commands update topics on our dotnet-store branch. I'll ping you over there on the PR with a link to the raw markdown and the review topic, which is the rendered topic for the published documentation. It takes a few hours for it to build the review doc, so I'll ping you this afternoon after the build. Thanks again for your help with this.

@mlorbetske
Copy link
Contributor

@guardrex @seancpeters should this be closed? It's been a while since the last update

@guardrex
Copy link
Contributor Author

@mlorbetske Yeah ... I only reopened on the possibility that the uninstall might get a feature whereby one could specify the short name and have the template uninstalled, regardless of whether or not the assets (the template folder or nupkg) was on disk.

@real-felix
Copy link

real-felix commented Mar 13, 2019

For those who have some of those "orphan" templates after experimenting, you can find how to remove them by launching the command:

dotnet new -u

that will list your installed templates. You can see the needed keys to uninstall them.

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

No branches or pull requests

4 participants