How to install "specific" Visual Studio templates - visual-studio-templates

In our project, we have created some custom Visual Studio templates. Then, the setup will copy them into VS ItemTemplates/ProjectTemplates folders (..\Microsoft Visual Studio 10.0\Common7\IDE). In order to make our VS templates effected, we have to execute devenv /installvstemplates to rebuild the VS template cache but this way takes much time since it will refresh all existing VS templates.
Is there any other way to do without executing the command above or any arguments could be passed along to specify a template? (i.e template name ...)?
Thanks in advance.

Related

How to execute PowerShell script while creating a Custom Project Template in Visual Studio 2015?

I am creating a Custom Visual Studio Project Template. This custom project template consists of two folders which needs to contain some binaries. These binaries has to copied from some server location. As these binaries will be updated periodically i can't simply enclose them while creating the custom project template. I would like to copy them from server location whenever the developer selects this custom project template the two folders inside their Visual Studio might get the latest binaries from the server location. I have to do this with PowerShell script only. Can someone help me on how to execute PowerShell scripts while creating custom project template in Visual Studio.
Why don't you create your own custom nuget packages? Then you only have to "refresh nuget packages" after creating the project from template.

How to share an SSRS Report Template across TFS?

The standard method of implementing a Reporting Services report template is to create an .RDL (report file) and place it in the Visual Studio Report Project template folder at C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject
Since this is a purely local approach, is there a way to implement a shared and source controlled template that can be used from the new item menu?
Our current solution for this issue is to store our templates in our report solution, and copy/paste them for new reports. Just wondering if there's a better alternative.
You need to create this as a .vsix extension and then share it. If you update the package and version all Visual Studio instanced that have it installed will prompt the user to update.
How to: https://blogs.msdn.microsoft.com/vsx/2014/06/10/creating-a-vsix-deployable-project-or-item-template-with-custom-wizard-support/
Although you can setup your own repo to load it from, It's much easyer to use http://marketplace.visualstudio.com for distribution.

Generated T4 Files Not Added to Project from Visual Studio Extension

I am trying to generate code scaffolding for an in-house API. I created a T4 template which includes several other templates for each code file to be generated. I then wrote a Visual Studio Extension (VSIX) with a WPF form to capture user input and initiate the transforming of the T4 template. I am doing all of this in Visual Studio Professional 2013.
This is what I followed to Invoke the Text Transformation in a VS Extension
https://msdn.microsoft.com/en-us/library/gg586947%28v=vs.120%29.aspx?f=255&MSPPError=-2147217396
When testing the templates locally using Run custom tool, everything works perfectly. However, when testing the VS extension in an Experimental Instance of Visual Studio, the problem I am having is that after the transformation has been invoked [calling ITextTemplating.ProcessTemplate], the generated files are not placed into my open project. I verified that they exist in their appropriate folders in File Explorer.
I have searched high & low and can't find anything that talks about this. Any ideas?
The custom tool is using the Visual Studio API (DTE object) to add the generated files to the projects. I built something very similar and that is what I had to do. This project is a bit old but it is a great starting point for seeing how this can be done.
Basically you need to get a reference to the folder you want to add the new item to and then call AddFromFile. Also don't forget to save the project after you add all the items.

How to remove duplicate class template in Visual Studio 2015

When I select menu add - new item in my project on solution explorer in Visual Studio 2015 and want select new class template i see duplication this template. How to fix it?
Besha,
I've encountered the same problem, which as I'm sure is caused by Xamarin item templates. These templates use the same definitions as native VS studio templates, e.g.:
Name Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="2245"
Thus, when VS shows you the items it ends up with duplicate names.
To fix the problem I've scanned all the template files (*.vstemplate) containing the mentioned above GUID and replaced the Name element with a text that suites my needs. E.g. for the Xamarin class I've changed it to be:
Xamarin C# class
instead of Package=".....
Note, that VS uses caching of templates and the caching is different for VS native templates and third party templates. In case of Xamarin, there will be ZIP files containing the templates and cached files with templates extracted from the archives. E.g.:
c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\3.11.785.0\T\~IC\IT\Code\GeneralClass.zip\
will contain the extracted templates, while the original archive is there:
c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\3.11.785.0\T\IT\Code\GeneralClass.zip
Your goal is to find the non-cached templates and change the Name element there.
Once you've found and fixed the name element, close Visual Studio, launch the command prompt as administrator, go to the
c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE folder
and run the following command:
devenv /installvstemplates
It will take a while.
Hopefully, after that you won't see duplicated class items.
Regards.
If you have Xamarin/Xamarin Studio installed (and don't use it), you can also just simply uninstall it, removing the class templates. Unity by default installs Xamarin Studio, and I simply remove it as I develop Unity projects with Visual Studio.

Installing Visual Studio Project Templates without deleting the ProjectTemplatesCache

I'm working on an installer that needs to add several files to AVR Studio 5, an IDE developed by Atmel that is based on the Visual Studio Isolated Shell. These files include project templates for the "New Project" dialog.
By experimenting, I found that I can successfully add the project templates and get them to show up in the dialog if I simply copy them into C:\Program Files (x86)\Atmel\AVR Studio 5.0\ProjectTemplates\ and then delete or rename C:\Program Files (x86)\Atmel\AVR Studio 5.0\ProjectTemplateCache\cache.bin. I have not been able to find any good documentation on how the Visual Studio ProjectTemplateCache folder works. It seems to contain the same files as the ProjectTemplates folder, plus the cache.bin file, so I'm not sure why it would be useful. After I rename cache.bin, Visual Studio does not regenerate it, which makes me worried that renaming it might have some permanent consequences. Is renaming cache.bin a bad idea? What problems can it cause?
Is there another, easy way to install new project templates? Ideally I would like something that is easier than creating a Visual Studio Extension (.vsix) file, as recommended in this previous StackOverflow question: Installing a custom project template with Visual Studio Installer project
The installer I am working on uses NSIS, if that matters.
For my isolated shell I copy my template .zip files to 'Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates' and '\ItemTemplates'. I then run my isolated shell with the command line '/installvstemplates'. This rebuilds the caches and when you next run the isolated shell, they show up properly.
I also had to target the isolated shell in my extension manifest files.
Have you tried any of these?
If per user project templates are fine, you can drop them in <My Documents>\AVRStudio\Templates\ProjectTemplates.

Resources