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

Build a UI in Visual Studio for Dotnet New Templates #481

Closed
RehanSaeed opened this issue Mar 24, 2017 · 70 comments
Closed

Build a UI in Visual Studio for Dotnet New Templates #481

RehanSaeed opened this issue Mar 24, 2017 · 70 comments
Assignees

Comments

@RehanSaeed
Copy link

RehanSaeed commented Mar 24, 2017

VS is where all the users are at for consuming templates. I'm having huge problems getting my current VSIX template working with VS 2017. Every VS upgrade breaks something which is hugely frustrating. I'd like to be in the template authoring business, not the VSIX authoring business.

Visual Studio Template VSIX

It would be great if there was an easier way to build a project template VSIX (or some other mechanism) around my template NuGet package with a feature selection UI built around template.json. That way template authors could easily release their templates to their biggest market. Whatever the mechanism for getting my template into VS, I'd like it to appear in the Visual Studio Gallery.

Icons, Logos & Banner Images

It would be great to include icons for the template and any symbols in the template. I propose extending the template.json file to add these. I've shown the values as URL's but they could equally be file paths relative to the .template.config folder:

{
  "name": "ASP.NET Core 1.1.1 MVC 6 Boilerplate API",
  ...
  "logo": "http://example.com/logo.png",
  "banner": "http://example.com/banner.png",
  "symbols": {
    "Swagger": {
      ...
      "icon": "http://example.com/swagger/icon.png"
    },
    "PrimaryWebServer": {
      ...
      "icon": "http://example.com/primarywebserver/icon.png"
      "choices": [
        {
          "choice": "Kestrel",
          "icon": "http://example.com/primarywebserver/kestrel/icon.png"
        },
        {
          "choice": "WebListener",
          "icon": "http://example.com/primarywebserver/weblistener/icon.png"
        }
      ]
    }
  }
}

Cross Platform Feature Selection UI

Another idea is to make the feature selection UI cross-platform so a potential extension could also be created for Visual Studio Code. A simple ASP.NET Core UI could be fired up as that's already cross platform. Once features have been selected and you hit ok, you shutdown the ASP.NET Core site and work the templating engine magic.

@sayedihashimi
Copy link
Member

sayedihashimi commented Mar 26, 2017

Hi @RehanSaeed thanks for the issue. This is something that we are very much interested in. We've already started working on it actually.

For the cli we are planning to implement --install, --uninstall, and --update for the cli in dotnet new.

For Visual Studio we are planning to create a new entry in the New Project Dialog which will launch a WPF dialog that allows you to:

  • View installed templates, and create a project from one
  • Install/Uninstall templates
  • Update templates

This WPF dialog would also handle prompting for the parameters that the template makes available.

With this model when you ship your template for dotnet new, it will be available also to Visual Studio. You wouldn't need to worry about any Visual Studio specific work (unless you wanted to customize that experience).

If you're specifically looking to create a new entry in the New Project Dialog, I think the best thing to do there is to create a new VSIX containing your .vstemplate which has a custom wizard to invoke the Template Engine. The code for our WPF dialog will be open source so you should be able to create such a wizard for your own specific scenarios. I can help you with this as well when the time is right.

With respect to the cross platform UI idea. I think its an interesting idea but, if we implemented that I think we will have one UI used across various different scenarios. This isn't the desired result. In Visual Studio when creating a project I want to go through the familiar UIs that I'm used to. It would be strange for VS to launch a UI that looked different. Also the same can be said about VS4Mac and other IDEs/Editors that are integrated with the Template Engine. The specific UI/UX needs to be implemented in a first class way for that specific scenario. So having a shared UI is not that useful.

@RehanSaeed
Copy link
Author

That sounds great. It would be great if the installed templates showed up as items in the VS New Project dialogue instead of having to click through to a separate templates screen. To do that, I suppose, you would need to add some kind of category property to template.json.

Regarding cross-platform, agreed it might look strange but I think VS Code should also have a UI that makes sense for creating projects.

@sayedihashimi
Copy link
Member

It would be great if the installed templates showed up as items in the VS New Project dialogue instead of having to click through to a separate templates screen.

This would require changes to the core New Project Dialog in Visual Studio. I'm going to have some discussions with that team soon, but that's not something that's likely to happen any time soon. It is one of my long term goals though.

but I think VS Code should also have a UI that makes sense for creating projects.

No disagreement. On the VS Code side I think it would be quicker if we (the community) create an extension.

@codewithtyler
Copy link

No disagreement. On the VS Code side I think it would be quicker if we (the community) create an extension.

I'd like to help with that.

@mlorbetske mlorbetske added this to Issues in Visual Studio Mar 29, 2017
@mlorbetske mlorbetske moved this from Issues to Requests in Visual Studio Mar 29, 2017
@mlorbetske mlorbetske moved this from Requests to In Progress in Visual Studio Apr 9, 2017
@mlorbetske mlorbetske modified the milestones: Backlog, 15.3-preview3 Jul 17, 2017
@neman
Copy link

neman commented Sep 18, 2017

I'm also interested in this feature. What is the status for this? VS 15.3 is released on August 14 and there is no mention of this feature (neither in the following four patches)
We built custom dotnet new template for our client, and they are complaining because they have to use CLI instead of VS.
Any progress on this or some change in milestone, since it's now in backlog?

@sayedihashimi
Copy link
Member

I posted an announcement a few weeks back, see #1209.

@panmona
Copy link

panmona commented May 24, 2018

@sayedihashimi Isn't it possible that VS makes this UI himself? I mean they have the metadata for the parameters and knows what templates are installed. Rider goes a similar way.

That other way seems way too complicated and time expensive.

@sayedihashimi
Copy link
Member

@maracuja-juice I've moved to a different team, so I can't really speak to this any longer. Hopefully someone else here can.

@Plac3hold3r
Copy link

Any update with adding a dotnet new template UI option in Visual Studio 2019? While Visual Studio 2019 preview 1 demos the updated startup and template creation process, it does not seem to offer anything in the way of additional dotnet new template support yet.

@bitbonk
Copy link

bitbonk commented Jan 2, 2019

We are really missing some guidance on how to create, install and use templates that work both in Visual Studio as well with the new dotnet cli or if that is not possible how to port one to the other.

What is the current state of the consolidation or interoperability of the two templating systems?

@Frogman7
Copy link

I considered working on a solution to this myself at one point but ultimately decided against it since the readme would suggest this will be officially supported at some point in the future. With some guidance I'd be willing to commit some time to assist with the official development of this feature.

@Thraka
Copy link

Thraka commented Jun 14, 2019

@seancpeters is there an update on this issue? This is something I'm also very interested in. It would make documenting .NET Core with Visual Studio and the CLI so much easier.

But I really think you guys should sync with the Visual Studio team and get this built into Visual Studio directly. It should just consume .NET Core templates directly without any other special dialog steps.

@seancpeters
Copy link
Contributor

seancpeters commented Jun 14, 2019

@Thraka - We've been discussing some plans to make the use of templates more uniform between VS & the Cli, but nothing definite at this point.

@dotMorten
Copy link

@seancpeters This issue has been going for a couple years now, and .NET Core 3.0 is shipping in a months time, and I can imagine with WPF and WinForms coming in, this really starts to be needed, as VS would be the main way to build those projects, rather than the CLI.

I'm trying to figure out how to ship my .NET Core WPF templates in a VSIX so they both work in VS and .NET Core CLI, but lack guidance on this.

@RehanSaeed
Copy link
Author

The VS tooling team just finished a redesign of the new project dialogue, lets hope they can now work on a UI for dotnet new.

I've started to think that it would be great to make a dotnet new ui command as a kind of global tool, not requiring Visual Studio at all. If you've seen the Vue CLI which does this, it's a pretty amazing experience?

@bitbonk
Copy link

bitbonk commented Aug 28, 2019

@DamianEdwards talks a little about their plans with templating on this ASP.NET Core community standup (somewhere around minute 50). The bad news is that it will probably still take quite a long time (far beyond .NET Core 3.1 timeframe would be my guess). The good news is that they are going for a solution that works across VS, VSMac and the CLI. I heard him say the word DSL.

@phenning
Copy link
Contributor

Using Visual Studio Version 16.8.0 with Show all .NET core templates in the New project dialog enabled I can't see any of the templates I have uploaded to an Azure DevOps package feed. The feed is configured as a package source in Visual Studio.
I can run the templates from the command line with dotnet new.

There is currently no mechanism for discovering the templates from feeds automatically.

What is supported today is the display and creation of a template installed via dotnet new --install from the command line to the CLI hive. The Visual Studio host will sync any templates found in this hive for use in Visual Studio. This assumes the template is compliant with guidance as described. The advantage of this feature is that templates can now be used within Visual Studio without the need for a stub vstemplate file.

@DavidJFowler
Copy link

There is currently no mechanism for discovering the templates from feeds automatically.

Hi @phenning, I don't think the template needs to be discovered from the feed, If I run dotnet new -l I can see my templates.

@jskeet
Copy link

jskeet commented Nov 12, 2020

@DavidJFowler: When you run dotnet new -l are you in a directory with a global.json somewhere? I believe templates are stored on a per-SDK basis, and it looks to me like VS takes them from .NET Core 5. I found that when I installed a template in a directory with no global.json anywhere in the hierarchy, it was then visible in VS.

@phenning
Copy link
Contributor

@DavidJFowler: When you run dotnet new -l are you in a directory with a global.json somewhere? I believe templates are stored on a per-SDK basis, and it looks to me like VS takes them from .NET Core 5. I found that when I installed a template in a directory with no global.json anywhere in the hierarchy, it was then visible in VS.

This is the most likely cause, assuming that the preview feature is enabled and the template is accessible via dotnet new.

If this still doesn’t work for you, let me know which template you are trying to use and I’ll install it locally and debug.

@DavidJFowler
Copy link

My templates are solution templates, rather than project templates. Could that be the reason?
I don't have a global.json in my directory hierarchy and I've tried with Use previews of the .NET Core SDK turned on and off.

@phenning
Copy link
Contributor

My templates are solution templates, rather than project templates. Could that be the reason?
I don't have a global.json in my directory hierarchy and I've tried with Use previews of the .NET Core SDK turned on and off.

That would be the cause then.

The type does needs to be "project" for use in the new project dialog. For multi-project templates, for example the Blazor template, if you don't specify any of the project files as primary outputs, Visual Studio will add all the discovered project files to the loaded solution. You can also specify the primary outputs explictly. The Blazor template uses the explicit method.

@phenning
Copy link
Contributor

@davidfowl We are planning to look at what if any differing behavior we need to have to support type: "solution". See sayedihashimi/template-sample#7

@sayedihashimi
Copy link
Member

@davidfowl try out my template analyzer, more info at https://twitter.com/sayedihashimi/status/1326622265144905731?s=20

@donJoseLuis donJoseLuis removed the triaged The issue was evaluated by the triage team, placed on correct area, next action defined. label Nov 22, 2020
@donJoseLuis
Copy link
Contributor

Template team, I removed the "triaged" tag so that in the next session, this issue is assigned to Phil's team.

@sayedihashimi
Copy link
Member

I think we can close out this ticket, we've already implemented the support in the previews of Visual Studio.

@jskeet
Copy link

jskeet commented Dec 1, 2020

@sayedihashimi: It's better than that - it's in the released (GA) version of Visual Studio - still behind a "preview features" flag, but you don't need a preview version of VS itself.

@RehanSaeed
Copy link
Author

@sayedihashimi Any ideas when the 'solution' template type will get released? Also interested in the timeline for the other issues raised in https://github.com/sayedihashimi/template-sample/issues.

@sayedihashimi
Copy link
Member

@jskeet yes, that is more accurate than what I posted.

@RehanSaeed we are hoping to get solution support into 16.9, but there is a chance it can slip to 16.10.

@rbwhitaker
Copy link

@jskeet

It's better than that - it's in the released (GA) version of Visual Studio - still behind a "preview features" flag, but you don't need a preview version of VS itself.

When is it expected to not be behind the "preview features" flag? Is it expected to become non-preview for 16.9? Or sometime after that? If so, is 16.9 still planned for release in December? I'm trying to get a feel for when this will be available out of the box without messing with settings.

@jskeet
Copy link

jskeet commented Dec 10, 2020

@rbwhitaker: I have no idea about any of those things, I'm afraid. I'm just a VS consumer like others.

@rbwhitaker
Copy link

Maybe I should be at-mentioning @vlada-shubina instead? Do you have any insight into the timing of the "Show all .NET Core templates in the New project dialog" feature becoming mainstream, and not behind a preview toggle? If this issue got closed, does that mean the next 16.9 preview will have it as a formal part of the program?

@vlada-shubina
Copy link
Member

Do you have any insight into the timing of the "Show all .NET Core templates in the New project dialog" feature becoming mainstream, and not behind a preview toggle? If this issue got closed, does that mean the next 16.9 preview will have it as a formal part of the program?

@sayedihashimi do you have any insight on this? Thank you.

@sayedihashimi
Copy link
Member

@rbwhitaker in 16.9 the preview flag will default to On. If users have any issues they can turn that flag off, but we are hoping that we will run into only a few issues. Let me know if you need any more info.

@rbwhitaker
Copy link

rbwhitaker commented Dec 10, 2020

@sayedihashimi, thank you for the answer. That was what I needed to know. Do we have a rough timetable for 16.9's final release? I believe I heard December (this month). Is that still the best guess?

@vlada-shubina thanks for helping get my question to the right people!

(And sorry for spamming like 5 messages. My cat jumped on the keyboard and somehow got my message posted like five times within a fraction of a second before I grabbed him.)

@sayedihashimi
Copy link
Member

sayedihashimi commented Dec 10, 2020

@rbwhitaker sorry, I am no at liberty to give any specific dates, but I do not believe that it will be released this year. I looked to see if there was any public message about the release date but I did not find any.

(And sorry for spamming like 5 messages. My cat jumped on the keyboard and somehow got my message posted like five times within a fraction of a second before I grabbed him.)

Haha, it's normally the dogs fault, but now it's the cats turn :)

@rbwhitaker
Copy link

@sayedihashimi

I am no at liberty to give any specific dates, but I do not believe that it will be released this year.

I swear I heard December, but the place I thought I heard it was in the .NET Conf videos, and after reviewing it, I don't see anything. It seems like I jumped to a conclusion somewhere. Thanks for helping me get straightened out! 😃

@sayedihashimi
Copy link
Member

@rbwhitaker no problem, glad I could help.

@rbwhitaker
Copy link

@rbwhitaker in 16.9 the preview flag will default to On. If users have any issues they can turn that flag off, but we are hoping that we will run into only a few issues. Let me know if you need any more info.

Any updates on this, @sayedihashimi? I've been watching the 16.9 Preview release notes carefully, and this change has yet to be called out. Is it still coming? Did it happen without being called out? Has it been delayed?

I know I can go enable this feature myself, but I've got a group of new devs that I work with, and getting easy access to the new template system will make the first steps of their C# journey much easier.

@sayedihashimi
Copy link
Member

sayedihashimi commented Mar 2, 2021

@rbwhitaker it will be on by default when 16.9 is released.

@bcausey88
Copy link

Love the concept, but unfortunately, this preview feature doesn't work for me. With version 16.11.8, I have it enabled and have 2 templates created as NuGet packages and installed using the CLI and they appear nicely in the CLI and I can create projects using the template from the CLI but the templates do not appear in the UI New Project Dialog. I've installed/uninstalled templates, restarted Visual Studio, cleared my Visual Studio cache, rebooted machine - all numerous times and to no avail.

I believe there must be something different in the template.json file that the UI needs that I'm not providing.

This may not be the right audience for this but I bet there are others struggling with this and I'm not alone. Maybe there is someone that can point me in the right direction. Any input and advice is appreciated.

Just for completeness here is my template.json file.

{
    "$schema": "http://json.schemastore.org/template",
    "author": "Blake C",
    "name": "Rock API Project",
    "description": "Project providing the barebones project for Rock APIs.",
    "identity": "rock.apikit.api",
    "shortName": "rock.apikit.api",
    "classifications": [ "Rock", "Web" ],
    "tags": {
      "language": "C#",
      "type": "project"
    },
    "sourceName": "Rock.ApiKit",
    "primaryOutputs": [
      {
        "path": "Rock.ApiKit.csproj"
      }
    ]
  }

@nvmkpk
Copy link

nvmkpk commented Jan 7, 2022

As far as I know, for the template to show in visual studio, it needs additional json file in some specific folder. I don't have the link handy but if I remember correctly I read it in either dev blogs or Microsoft docs site somewhere.

@sayedihashimi
Copy link
Member

@bcausey88 can you share a sample package that you are having issues with?

@nvmkpk in VS2022, you no longer need to add a host file. See https://aka.ms/netcore-templates.

@phenning
Copy link
Contributor

phenning commented Jan 7, 2022

@bcausey88 I took a look at the feedback ticket you submitted and asked for some additional information to help diagnose.

Do you have .NET 6 installed on this machine by chance? If you are, it could be that you are installing the template into the NET 6 template hive, which would not be readable by Visual Studio 2019. You can see by looking at the output of dotnet --info and see if the first section is similar to the following. If that is the case, you can create a global.json in a folder and pin the sdk version to the version of .NET 5 which is also installed. Then, make sure you run dotnet new --install from within that folder.

Visual Studio 2022 will correctly recognize templates installed into the .NET 6 template hive.

.NET SDK (reflecting any global.json):
 Version:   6.0.200-preview.21617.4
 Commit:    58f9685dd5

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
Visual Studio
In Progress
Development

No branches or pull requests