Тёмный

Custom Item Templates in Visual Studio 

IAmTimCorey
Подписаться 420 тыс.
Просмотров 44 тыс.
50% 1

Опубликовано:

 

12 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 92   
@Qu4ntvm
@Qu4ntvm 9 месяцев назад
THANK YOU!!!! I was tired of constantly changing the using statements for making a Terraria mod, and researching didn't help. Before I gave up, I searched on RU-vid and found this amazing video. Thank you!
@IAmTimCorey
@IAmTimCorey 9 месяцев назад
You are welcome.
@kiquenet
@kiquenet 4 месяца назад
Terraria ???
@RalfsBalodis
@RalfsBalodis 4 года назад
0:00 - Intro 1:56 - Getting started: Creating the demo application 3:26 - Item template: Creating a custom item template 9:00 - Item template: Importing and using your custom template 14:26 - Advanced template: Variables in the template 17:26 - Advanced template: Adding ILogger 20:22 - Advanced template: Custom icons (Metro Studio) 22:08 - Advanced template: Code behind the template 29:11 - WPF templates: Creating WPF Project 36:00 - WPF templates: Creating the templates 38:05 - WPF templates: Organizing templates 40:35 - WPF templates: Using the custom templates 42:41 - C# Item Template project 46:27 - Sharing your templates 48:37 - Project Template 50:05 - Concluding remarks
@IAmTimCorey
@IAmTimCorey 4 года назад
Excellent, thank you. Added
@ebarednaxela
@ebarednaxela 2 месяца назад
Thanks Tim! Just wanting to learn making templates in VS Studio 2024 Preview and this video game me a headstart. Please tag me when you redo this video on .Net 8. Thanks again!
@IAmTimCorey
@IAmTimCorey 2 месяца назад
You are welcome.
@andywalter7426
@andywalter7426 2 года назад
Thanks to your video, I managed to create a template that has a starting point for a class that has to be a certain format to work with external tools (like a class being readonly record struct class).
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@vincentanzelone8705
@vincentanzelone8705 Год назад
Fantastic video. Just what I was looking for. Thank you so much.
@IAmTimCorey
@IAmTimCorey Год назад
Awesome! I’m glad it was helpful.
@Locklesh
@Locklesh 2 месяца назад
If anyone is having issues finding their template that's for a language other than c#, make sure you you open the .vstemplate file and change the ProjectType to the language you need.
@IAmTimCorey
@IAmTimCorey 2 месяца назад
Thanks for sharing!
@mdrahbarahmedkhan
@mdrahbarahmedkhan 4 года назад
Hi Tim, please do a video on Dependency Property and Attach Property in WPF. I know only you can make us understand in a simple way. ☺
@IAmTimCorey
@IAmTimCorey 4 года назад
I will add it to the list. Thanks for the suggestion.
@AkshayKumarTK
@AkshayKumarTK 4 года назад
+1
@IAmTimCorey
@IAmTimCorey 4 года назад
I will add it to the list. Thanks for the suggestion.
@zohar127
@zohar127 4 года назад
I create plug-ins for AutoCAD so I followed your video to create a project template for AutoCAD dev, which involves referencing a bunch of their dll files and changing some project properties to get VS to launch AutoCAD when debugging. Unfortunately for me I am on VS2019 so it doesn't actually show up but I'm sure once that issue gets solved it'll be totally awesome!
@IAmTimCorey
@IAmTimCorey 4 года назад
I'm working on tracking it down. I'll do a video as soon as I can on it.
@ladoleskovec281
@ladoleskovec281 3 года назад
During the video you mentioned you haven't found a good way in VS 2019 to find created project templates. I know you said project templates deserve a separate video, but after you referred to this video in your MvvmCross introduction video I tried creating a project template for MvxProject.Core using your guidence here. When looking for it, I managed to find this template using the search bar in Create a new project UI (just typed in "mvx" and it was on top of the hits). I was quite impressed the project even came with the MvvmCross NuGet package installed. I included a StarterViewModel that gets registered in the App.cs and included a constructor with blank command as a prebuild help. I at first wanted to ask if there's a way to make this StarterViewModel customizable, but later figured out I can just rename the class :) Thanks again for an awesome video!
@IAmTimCorey
@IAmTimCorey 3 года назад
Not being able to find a template was a bug that was fixed in an update of Visual Studio.
@mrrcomp
@mrrcomp Год назад
Hi. Excellent tutorial. Do you have any info on how we can change the Scaffolding Templates?
@JoeBonez
@JoeBonez 4 года назад
Great video. All these years, and I never knew that the export function would replace the class names, etc. with the placeholders. I always did it by hand before exporting. The template I used most often was a project template for a base MVVM project with all the folders and resources I used. Haven’t tried to recreate it with VS 2019, disappointing to hear it doesn’t work.
@IAmTimCorey
@IAmTimCorey 4 года назад
I'm glad you learned something new. I'm tracking down the project issue. I'll get it figured out.
@martinsmifff
@martinsmifff 4 года назад
Tim, this was very usefull thanks. Is there any chance you could do a video about creating a "dotnet new" template?
@IAmTimCorey
@IAmTimCorey 4 года назад
It is on the list and coming soon.
@realgrinsekater
@realgrinsekater 2 года назад
First of all, great video! I wanted to ask if there is any possible chance to install used assemblies while creating a custom template, so you dont have to add assemblies afterwards! Thank you for your time.
@bartomiejciurla8472
@bartomiejciurla8472 4 года назад
Very helpfull video. Thanks!
@IAmTimCorey
@IAmTimCorey 4 года назад
Glad it was helpful!
@schlaf-michelatwork6532
@schlaf-michelatwork6532 2 года назад
Dear Tim, great video! But can you tell how do i remove those templates again? Deleting these files in the templates directory dosn´t work. Means files are deleted, but still still shown in Visual Studio Dialog Menue? Thank you sincerely.
@vincentanzelone8705
@vincentanzelone8705 Год назад
Thanks!
@IAmTimCorey
@IAmTimCorey Год назад
Thank you!
@briantaylor7695
@briantaylor7695 2 года назад
Is it possible to create a item template for a "razor page with a model", basic class template works but this wont show up when I select new item?
@99MrX99
@99MrX99 4 года назад
Hi Tim, great video! Just found out you can build the ItemTemplate project and it will put out the .zip file in the debug folder
@IAmTimCorey
@IAmTimCorey 4 года назад
Awesome!
@IAmTimCorey
@IAmTimCorey 4 года назад
Cool.
@thethomasproject
@thethomasproject 3 года назад
Hey Tim have you ever ventured down the road of customized scaffolding to build crud operations?
@IAmTimCorey
@IAmTimCorey 3 года назад
Nope.
@Kaalund1989
@Kaalund1989 Год назад
is the sharing part vid. out? :) i want to make some for my fellow programmers on a private feed so hope it is :D
@slinky7355
@slinky7355 Год назад
Using the new shorthand namespace *namespace $rootnamespace$;* doesn't seem to work - VS helpfully converts it to the old style with curly braces.
@gdiastj
@gdiastj 4 года назад
When creating a item template, is it possible to use part of the $itemname$? For instance, I'm creating the repository classes for my models and want to reference the model class. Like the model name is "Product", the template will create the "ProductRepository" class and I want to reference "Product" inside. Someone?
@IAmTimCorey
@IAmTimCorey 4 года назад
Not that I know of.
@gdiastj
@gdiastj 4 года назад
@@IAmTimCorey I found a way! Let's say I have a model named "Product" and wish to name the repository and service class like so (ProductService and ProductRepository). Naming the class itself is not the issue, I also want the repository template to reference the correct model and the service template to reference the repository. This is my TargetFileName on the .vstemplate file: $fileinputname$Service.cs. That way, when naming the file I'll go by the model name "Product" only and VS will fill the rest for me and the filename will be: ProductService. This way I can use the same $fileinputname$ inside the .cs to "automatically" reference other layers and model: public class $safeitemname$ : BaseRepository, I$safeitemname$ will translate to public class ProductRepository : BaseRepository, IProductRepository And the Service template: public class $safeitemname$ : I$fileinputname$Service { private readonly I$fileinputname$Repository _$fileinputname$Repository; private readonly I$fileinputname$ReadRepository _$fileinputname$ReadRepository; public $safeitemname$(I$fileinputname$Repository $fileinputname$Repository, I$fileinputname$ReadRepository $fileinputname$ReadRepository) { _$fileinputname$Repository = $fileinputname$Repository; _$fileinputname$ReadRepository = $fileinputname$ReadRepository; } } Thanks for the awesome video! Helped me a lot finding this workaround.
@cathmeister9510
@cathmeister9510 4 года назад
@@gdiastj I was looking to do something like this. Thank you for posting this.
@vionmiu7589
@vionmiu7589 4 года назад
Great video, Tim. Just wondering, is it possible to pass a $rootid$ from one item template to another? Apparently, I have one item template dependent to another.
@IAmTimCorey
@IAmTimCorey 4 года назад
I don't believe so, no.
@John-3.16
@John-3.16 4 года назад
Hi Tim, could you please make video for generate class template for .net core because 4T is not available on .net core. Example, generate models from sql database. Regards
@IAmTimCorey
@IAmTimCorey 4 года назад
I will add it to the list. Thanks for the suggestion.
@kiquenet
@kiquenet 4 месяца назад
Great mister! Applies to Visual Studio Community 2022 ? not for Visual Studio Code
@IAmTimCorey
@IAmTimCorey 4 месяца назад
Yes, this is for Visual Studio 2022, not VS Code. I'll cover VS Code separately.
@schlaf-michelatwork6532
@schlaf-michelatwork6532 2 года назад
I forgot to tell i am working with VS 2019. and i tried to find help on myselfe !
@andywalter7426
@andywalter7426 2 года назад
What is your suggestion if you have a template you created that you want to share but the developers are not on the same network but want to share with others around the world?
@IAmTimCorey
@IAmTimCorey 2 года назад
Use a NuGet package.
@honeymaplegrove1909
@honeymaplegrove1909 4 года назад
When I the to add a new project (c#-All Platforms-Extensions) there are "No exact matches found". What do I need to do to have there populated. BTW - I find your approach and presentation "PERFECT". Kudos.
@IAmTimCorey
@IAmTimCorey 4 года назад
Do you mean you can't find your template? If you put it in that location, it should show up. You might want to make sure your Visual Studio 2019 is the latest version. There was a bug in earlier versions.
@nwdreamer
@nwdreamer 4 года назад
Hi Tim, when you can finally do the video for the Project Template, can you make a WPF MVVM one all set up the way it should be? Kind of a accumulation from many of your training videos showing not only the folder separation for MVVM, but the folders and projects that use a separate class library and interfaces. :-)
@IAmTimCorey
@IAmTimCorey 4 года назад
You are kind of reading my mind. I've been working on something like that. It can't do multiple projects but configuring Caliburn Micro is probably something I'll do.
@AvgDan
@AvgDan 2 года назад
It really sucks that VS doesn't work well with recognizing changes to the templates if it's a symbolic link to a file in a different folder. If I update the files in the template and restart VS it still uses the old template unless I delete the symbolic link and recreate it. I would have liked symbolic links to work because I could simply point all dev machines to a repo for each file so all developers get an update when I update the template.
@IAmTimCorey
@IAmTimCorey 2 года назад
Yep, that is frustrating. You can put these in a NuGet package, but last I heard they still had a bug where the package wasn't updating the templates like it should. Might have fixed it by now.
@AvgDan
@AvgDan 2 года назад
@@IAmTimCorey I've decided to simple but a batch file in the repo along side the templates. Users will just have to double-click the .bat file to update the templates in VS.
@didac3918
@didac3918 4 года назад
Is there any way to add the custom item template to the quick add drop down menu, so I don't have to click on new item and then select my custom item template (add > new item > item). I want to be able to select it immediately (add > item) just like I can immediately select a default class, window, page or user control etc. without first clicking on new item
@IAmTimCorey
@IAmTimCorey 4 года назад
I believe that would be an extension of Visual Studio itself, not just an item template.
@AbubakrMahdiSan
@AbubakrMahdiSan 4 года назад
Hi Tim , nice video , i asked you before about "Repository Pattern" video , what its rank now in your list? Thanks Tim
@IAmTimCorey
@IAmTimCorey 4 года назад
It is still on there, I just have a lot to cover. It is one of my top priorities in the patterns and practices category, though.
@michaellenart1807
@michaellenart1807 4 года назад
This was great and helped me. Unfortunately it seems the Visual C#\ASP.NET Core app projects the custom item templates dont work. What am I missing?
@IAmTimCorey
@IAmTimCorey 4 года назад
They should work.
@michaellenart1807
@michaellenart1807 4 года назад
IAmTimCorey They don’t. They show up in the class library project in the solution but not the ASP.NET Core project. They also dont show up in my other ASP.NET Core Projects in the solution. Any guidance will be greatly appreciated.
@santiagopiaggio2099
@santiagopiaggio2099 4 года назад
Hi tim! Awsome tip. Sorry to bother but could you answer this quick question? On the WPF of TimCo Retail Manager -> we initialized the HttpClient like this: private void InitializeClient() { string api = ConfigurationManager.AppSettings["api"]; _apiClient = new HttpClient(); _apiClient.BaseAddress = new Uri(api); _apiClient.DefaultRequestHeaders.Accept.Clear(); _apiClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } How would that change on a MVC project asp.net.core? I understand if you don't have the time for this! Thanks in advance
@IAmTimCorey
@IAmTimCorey 4 года назад
We will be covering that. Since we moved to .NET Core, we will be transitioning it over to a HttpClientFactory (still in WPF). We would do the same thing if it were in an ASP.NET Core project.
@responsibleparty
@responsibleparty 4 года назад
A warning about storing your files on OneDrive: My smart phone came with OneDrive and so I signed in from that device. There were some documents that it was handy to access from my mobile device. Some time later, I upgraded phones. This process involves deleting everything from the old phone (performed using software designed for this at my mobile phone provider). Some time after, I realized all my OneDrive content had been deleted. Unfortunately, I didn't realize this until after the period that Microsoft hangs on to deleted files and there was no way to recover them.
@IAmTimCorey
@IAmTimCorey 4 года назад
It sounds like you had a bad tool. I've wiped multiple phones without an issue (also multiple Windows machines).
@problemchild959
@problemchild959 4 года назад
any chance you know how to add it to the context menu ? like if I right click a folder/project go to add it has a few tiems like new item, at the bottom is class which is handy, but I love to add a couple items to that which I use very frequently (monobehaviour for unity, interface, etc) I know its possible because resharper would do it (I can't afford the upgrade cost for vs 2019 support tho)
@IAmTimCorey
@IAmTimCorey 4 года назад
That's a bit more complicated than I can share in this message but I'll add that to the suggestion list.
@problemchild959
@problemchild959 4 года назад
@@IAmTimCorey awesome I have searched google for a week and the docs and have come up with nothing :(
@techdhoon5417
@techdhoon5417 3 года назад
Why its not working while adding class in MVC Solution
@IAmTimCorey
@IAmTimCorey 3 года назад
I am not sure what you are asking. If it isn't working for you, check for any errors. You might have missed something small.
@mbfub
@mbfub 3 года назад
First of all great video. It's made with alot of care and going over every detail imaginable. However I got an issue when using those templates in my own projects. When I create the SimpleClassTemplate from the video I can use it without issues in any new Project. However I can't use the new template in any Project that existed before I created the template. Any idea why that might be the case? Thanks alot :)
@IAmTimCorey
@IAmTimCorey 3 года назад
Not sure. Maybe it is a project type issue (Core vs Framework).
@mbfub
@mbfub 3 года назад
I found the solution: all created templates through the template export only work in Microsoft NET Sdk projects, other projects like Microsoft NET Sdk Web don't work. In order for those to work you need to edit the vstemplate file with the TemplateGroupId your project uses which is AspNetCore in my case. Like this "AspNetCore " Thanks for the hint with the "project type" that helped me figure it out!
@bromine35
@bromine35 3 года назад
How can I do basic string manipulation in the template? Such as $safeitemrootnames.ToLower()$
@rafaeltab
@rafaeltab 4 года назад
Mister tim, if I got to iamtimcorey.com it gives doesn't give me your page. I suspect that this is because you only pointed www. to your page instead of also the empty version. Now you get an error page saying that an account is suspended
@IAmTimCorey
@IAmTimCorey 4 года назад
That should be resolved. Thanks for pointing it out.
@rafaeltab
@rafaeltab 4 года назад
@@IAmTimCorey can confirm that it is resolved and no problem
@rajenlenka7806
@rajenlenka7806 4 года назад
Hello Tim could you please make a video on weak references!!!!
@IAmTimCorey
@IAmTimCorey 4 года назад
I will add it to the list. Thanks for the suggestion.
@rajenlenka7806
@rajenlenka7806 4 года назад
@@IAmTimCorey ohh I didn't think I would get back a reply ...Thank you so much ..🙂🙂
@pierreplourde
@pierreplourde 2 года назад
It’s pronounced “SEE go you eye”. 😉
@IAmTimCorey
@IAmTimCorey 2 года назад
Interesting. Thanks for sharing.
@janne_kekalainen
@janne_kekalainen 4 года назад
Something useful for once (not into web apps)
@IAmTimCorey
@IAmTimCorey 4 года назад
I'm glad you found it useful.
@blabli3483
@blabli3483 2 года назад
Great video. You should try not treating people like real dumb shit. A lot of things do not need explanation.
@IAmTimCorey
@IAmTimCorey 2 года назад
I’m not. I’m treating them like they are learning. No one was born knowing C#. If I didn’t explain the things that were “obvious” to me, I wouldn’t have made the video. We are all at different places with our knowledge. I teach to a broad audience and want to ensure I allow as many of them as possible to understand what I’m teaching.
Далее
Custom Project Templates in Visual Studio 2019
42:19
Просмотров 57 тыс.
ДОМИК ДЛЯ БЕРЕМЕННОЙ БЕЛКИ#cat
00:45
Intro to Unit Testing in C# using XUnit
1:42:09
Просмотров 414 тыс.
Code Flappy Bird in Java
54:02
Просмотров 80 тыс.
C# Dependency Injection with Autofac
54:45
Просмотров 295 тыс.
ДОМИК ДЛЯ БЕРЕМЕННОЙ БЕЛКИ#cat
00:45