How to remove duplicate class template in Visual Studio 2015 - visual-studio

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.

Related

Modifying external DebuggerDisplay with autoexp.cs in visual studio 2015

It's possible to alter the way the VS debugger displays types even for types you don't own by altering autoexp.cs.
However, in my installation this file does not exist in My Documents/Visual Studio 2015/Visualizers/ nor in another folder. It does exist in the 2013 folder: My Documents/Visual Studio 2013/Visualizers/autoexp.cs
Did its location change? Has the functionality been (re)moved?
It is still possible to place visualizer dll's in this folder, the file just isn't there by default anymore.

Editing "testproject.zip" to stop "UnitTest1.cs" being created

I've been modifying the VS2010 item and project templates so each time we do a "new project" or "new item" we get it created in a format that works for us. This is all working fine; if we create a new class library we get it with the references we've set up and it doesn't create the "class1.cs" file - that all works. We've made a similar change to the TestProject.zip file that lives in:
C:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\IDE\ProjectTemplates\CSharp\Test\1033
Gone through the same process of zipping it back up, copying it over top of the original and refreshing the cache. However for the test project we can't stop it creating the default "unittest1.cs" file. All of our other changes to the test project are working fine but we just can't stop it creating the "unittest1.cs" file. It was never in the template or csproj file originally so I'm not sure what is creating it.
Can anyone help? What creates the default test file for the test project - I'm wondering if it's a reference to the wizard that is in the template file but have no idea what changes would be needed.
Close Visual Studio
Extract BasicUnitTest.zip from:
C:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\IDE\ItemTemplates\CSharp\1033
Open BasicUnitTest.vstemplate
Remove <ProjectItem ReplaceParameters="true">UnitTest.cs</ProjectItem>
Zip BasicUnitTest.vstemplate into BasicUnitTest.zip (excluding UnitTest.cs)
Go to:
C:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\IDE\ItemTemplatesCache\CSharp\1033
Delete UnitTest.cs and replace BasicUnitTest.vstemplate with your modified copy
On the next run of Visual Studio you should see the modified UnitTest
Though you can do this for every default template, I recommend creating a new template based on the BasicUnitTest.zip instead of overriding the ones shipped with Visual Studio. It's easier, safer and won't be overwritten by future service packs.

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.

Place a custom template in VS 2010 New File dialog

I'm trying to create a Visual Studio template that should appear in the New File dialog of Visual Studio 2010. No solution or project needs to be opened in order for my template to appear.
So far I know how to place my template in the Add New Item dialog, but can't find info on how to place it in New File dialog.
How can this be achieved?
Solved this by making my WiX installer put my template (a .mysql file) in a subfolder of my vsix extension folder (which goes a couple of levels below C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions) and then modifyied my .pkgdef file to add an entry to the Windows Registry that will specify that same dir as the TemplatesDir for this template:
[$RootKey$\Projects\{A2FE77E1-B743-11D0-AE1A-00A0C90FFFC3}\AddItemTemplates\TemplateDirs\{79a115c1-b133-4891-9e7b-242509dad272}\/1]
#="#105"
"Package"="{79a115c1-b133-4891-9e7b-242509dad272}"
"TemplatesDir"="$PackageFolder$\\Templates"
"SortPriority"=dword:00000020

How to install "specific" 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.

Resources