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

Unable to see new project template in Visual Studio #40

Open
wdorsett84 opened this issue Aug 4, 2021 · 14 comments
Open

Unable to see new project template in Visual Studio #40

wdorsett84 opened this issue Aug 4, 2021 · 14 comments

Comments

@wdorsett84
Copy link

I'm working on creation a solution template with multiple projects but I am not able to see the new template in Visual Studio 2019/2022 Preview and VS for Mac New dialog. I tried using the sayedmulti template in this repo and it's also not displayed in the new dialog. I've followed the Common Issues in the readme but to no luck. The template does show up in dotnet cli and Rider though. Are there any other options I can try? I created the template in vscode if that helps. Below is my folder structure.

Project.nuspec
src
.... Content
....... ApiTemplate
.......... .template.config
.............. icon.png
.............. ide.host.json
.............. template.json
.......... nuget.config
.......... Project.sln
.......... src
.............. Project1
.............. Project2
.............. Project3
.......... test
.............. TestProject3

@sayedihashimi
Copy link
Owner

Visual Studio doesn't currently support templates installed via the local folder system, we are working on that support. To get templates to appear in VS you'll need to install via the nuget package (.nupkg file). From the description here it sounds like you are installing with the local folder path. If so, please install with the .nupkg file and then see if they appear in VS. You'll need to restart VS after installing the template pack to get them to appear.

@wdorsett84
Copy link
Author

@sayedihashimi I am installing the template using the nuget package (sorry). I just illustrated the folder structure as above. I build the nuget package from the nuspec file mentioned from your visual studio toolbox mini series. Using the template in your repo only exposes the sayedweb template and the sayedtool template. The other two templates aren't displayed in VS or VS for Mac. I've restarted VS and having a hard time getting them to display.

@sayedihashimi
Copy link
Owner

@wdorsett84 what version of VS are you using? Make sure that the option is enabled in Preview Features https://github.com/sayedihashimi/template-sample#how-to-enable-cli-templates-in-visual-studio-and-visual-studio-for-mac. You'll also need to restart VS after running dotnet new --install [path to .nupkg]. If that doesn't work, please share your .nupkg file so that I can try it out to see what's happening.

@wdorsett84
Copy link
Author

@sayedihashimi Here are the versions:
Visual Studio 2019 Version 16.10.3
Visual Studio 2022 Version 17.0.0 Preview 2.0
Visual Studio 2019 for Mac Version 8.9.5 (build 4)

The package can be found here

@sayedihashimi
Copy link
Owner

@wdorsett84 the template is appearing fine for me in VS2022 Preview 2 after I installed with dotnet new and restarted Visual Studio. I did notice that I wasn't able to create the project in VS though, it crashes for some reason. I've filed an internal bug, hopefully @phenning can take a look at that soon to see what's happening.

I'm not sure why it's not appearing for you. Can you verify that you are able to create a template with dotnet new? If that doesn't work then it will not appear in VS.

image

@wdorsett84
Copy link
Author

@sayedihashimi As part of my template, I restore the packages and some packages are on a private feed that requires authentication. Authentication would fail after dotnet new if you don't have authorization to access the private feed. Could that be the reason it's not showing up in VS? Should I remove that action from the template?

@sayedihashimi
Copy link
Owner

@wdorsett84 that is likely related, but it still shouldn't crash VS. Phil is taking a look, and we will get back with more details soon.

@VaclavElias
Copy link

VaclavElias commented Aug 6, 2021

I have got the same problem, I installed the local package as mentioned above by @wdorsett84, both my package and yours is appearing in the console, and it is working from the dotnet cli but they don't appear in the Visual Studio Create a new project dialog. I also enabled it in the Preview Features and restarted a few times..

image

@sayedihashimi please reveal the missing secrets 🤣.

I have got this:
Microsoft Visual Studio Professional 2019
Version 16.10.4

@phenning
Copy link

phenning commented Aug 6, 2021

I haven’t had a chance to look at your specific package as of yet. I plan on doing so today.

However, what is happening as far as general visibility could be caused by if you have NET 6 preview installed and are installing the templates into that hive. In 16.10 the NET 6 hive will not be recognized as 16.10 is not the minimum version for NET 6. You can pin to the best version of NET 5 you have on your machine via global.json in a folder and run the dotnet new install command from that folder in order to force the template to be installed into that versions hive. VS prior to 2022 preview 3 will generally attempt to use the highest version of the CLI it can find regardless of any pinning.

if you don’t have NET 6 installed, the problem could be similar. Make sure that the location you ran the dotnet new install command from was not pinned to a lower version of the SDK.

Also, if you installed via dotnet new, then updated your SDK install to a newer version, this could also impact what templates are seen in Visual Studio.

You can check your %userprofile%.templateengine\dotnetcli folder to see which version of the SDK was used by dotnet new. Each versioned folder there will contain a packages folder, which you can inspect to see if the package is installed there.

The CLI/VS package sync has been changed in Visual Studio 2022 preview 3, so most of this won’t apply I’m that case.

@VaclavElias
Copy link

Thanks @phenning.

I can confirm that by adding global.json and specifying 5.0.302 I can now see the template in the Visual Studio 2019. It was defaulting to .NET 6 as you mentioned because I also have Visual Studio 2022 installed (I am also VS fan 😂).

@phenning
Copy link

phenning commented Aug 6, 2021

@wdorsett84 I can't grab the template pack off that drop box link for some reason. Are you perhaps having the same problem with .NET 6 that is preventing it from being shown in Visual Studio 2019? Or do you perhaps have it installed to an entirely different pinned SDK?

If you can fix the link to the template pack, I can investigate why Sayed was seeing a crash on creation.

@sayedihashimi
Copy link
Owner

@phenning im pretty sure that I attached it to the AzDo bug.

@phenning
Copy link

phenning commented Aug 6, 2021

@sayedihashimi you did. I was able to install it and see it both in VS 2022 Preview 3 and in 2019 16.11 No crash in either case when trying to create the project.

@wdorsett84 I have another thought as to why you may not be seeing the template in Visual Studio 2022 Preview 2.

I noticed your template targetted net 5.0, but Visual Studio by default only chooses NET 6 in Preview 2.

We made a change in Preview 2 which required the appropriate runtime to be installed as part of the Visual Studio installation explicitly. These options can be found under the Individual Components tab of the installer.

Can you check to make sure that you have NET 5 runtime explicitly enabled for that Visual Studio 2022 instance.

We actually removed this restriction from Visual Studio 2022 Preview 3, after some some feedback. We will now display the templates as long as an associated runtime is installed, even if it is installed separately from Visual Studio.

@wdorsett84
Copy link
Author

Thanks @phenning

I too can confirm that the global.json fixed the issue with Visual Studio 2019 so that's great. However, I have Net 5.0 runtime enabled under the Visual Studio 2022 install but still the template is not displayed. It's also not displayed on VS for Mac.

Since the template is now displayed in Visual Studio 2019, Jetbrains Rider and dotnet cli this gets me past my initial issue. However, would love to see it working on VS for Mac and Visual Studio 2022. If you need me to provide you anything, please let me know.

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

No branches or pull requests

4 participants