VS2013 create new class from template - visual-studio

Hi is this possible to create some template for Visual studio, that when I create new class it will contains some description in header ?

On Visual Studio 2012 you could do something like this:
Find the files
C:\\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\Code\1033
The file you want is in an appropriately named folder. If you open the Class folder you will find the following 2 files:
Class.cs
Class.vstemplate
Backup the original files
Change the Class.cs template file
Save your changes
Tell Visual Studio about the changes
Your new changes will not be loaded unless you explicitly tell Visual Studio to reload all templates.
Close Visual Studio (or the change swill not show until next time you run it)
Open a command prompt (you should run this as Administrator if you are not an admin of the machine).
Change to the IDE folder a few levels above the template folder (e.g. to C:\\Microsoft Visual Studio 10.0\Common7\IDE)
Run the following command:
devenv.exe /installvstemplates

Related

How to change icon of file based on file type in Visual Studio Extension

ITNOA
I have a GitHub project for Visual Studio Ansible extension, in this extension I want to change icon of ansible file in Visual Studio (.ansible and .ansible.yaml) based on file extension, but I do not know How to do it?
Anybody know to How to do it?
I write extension for Visual Studio 2022
related to https://github.com/MicrosoftDocs/visualstudio-docs/issues/8966#issue-1588941743
Updated 2/17/2023
I think it is related to https://learn.microsoft.com/en-us/visualstudio/extensibility/internals/manifest-from-resources?view=vs-2022
and based on How to add custom icons to solution explorer in Visual Studio I try to add resources and image manifest, but my file display void instead of display correct icon, and I do not know my mistake
I update source code, that you have see it https://github.com/soroshsabz/visualstudio-ansible/tree/features/5-add-syntax
related to https://developercommunity.visualstudio.com/t/New-icon-for-custom-file-type-is-not-d/10283644
thanks

How to add existing Template to Visual Studio?

Particularly for VS.NET 2013, how do you add a template? I've created a custom template. VS.NET adds it to \Libraries\Documents\Visual Studio 2013\Templates\ItemTemplates. I'd like to know import that template into VS.NET on a different machine.
When I rename the zip template in the above location, that name doesn't show up in the add new item dialogue box in VS.NET. Are there any steps for adding a template?
Maybe you can add the template to [Visual Studio installation path]\Common7\IDE\ItemTemplates\ of the other machine.
And then run the command devenv /installvstemplates in your Developer Command Prompt
Source:
http://msdn.microsoft.com/en-us/library/ms241279.aspx

vsix opens visual studio

I seem to have got my system into a bit of a pickle with respect to Visual Studio extensions.
Normally I would use Nuget.
When an extension is not on Nuget, I'd download the vsix file and double-click on it to start the installation process. But now, when I double-click on the vsix file, it opens it in the Visual Studio text editor, treating it as a file to be edited, rather than executing it as a file to be executed.
Anyone know how I can restore the correct, intended behaviour?
Thanks
First way: if you open regedit and see keys under HKEY_CURRENT_USER\Software\Classes.vsix, just delete that entire key. That should allow the global registrations in HKLM to take effect again.
Otherwise, right click on the file, Open With, and choose "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe".

How to move Visual Studio's 'My Code Snippets' folder to another drive?

A simple question for which I couldn't find a setting or an answer:
I relocated my Documents folder in Windows to another drive. How do I change the My Code Snippets folder path in Visual Studio 2012 from the default to the new location?
The default is in my Documents folder on C:.
C:\Users\Virtlink\Documents\
Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets
But I moved my Documents folder to my drive D:, but Visual Studio didn't pick up on this change and forces the creation of the folder on C:. This causes some weird behavior with exclamation marks next to My Code Snippets in the Code Snippets Manager, and errors on importing snippets.
The folder Windows directs me to when I open My Documents from my user folder is D:\Personal\, and I want the code snippets there too:
D:\Personal\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets
If necessary, I wouldn't mind moving the whole Visual Studio 2012 subfolder. I just can't find out how to set that in Visual Studio.
The UI doesn't make it completely obvious what the buttons are for, but this can actually be done in two simple steps:
Step 1. In Code Snippets Manager, select the folder that points to the disk location you no longer use, and click Remove:
Step 2. Click Add...
...and select your new folder:
That's it! Your new folder is now active in Code Snippets Manager.
Code Snippet folders don't seem to be directly editable in the Visual Studio IDE (that I could find). They are stored as registry entries, so you have to edit these settings directly.
For Visual Studio 2012 the registry settings are located in:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Languages\CodeExpansions\Visual C#\Paths
The value is called 'Microsoft Visual CSharp', and lists all the different folders separated by semicolons:
%InstallRoot%\VC#\Snippets\%LCID%\Visual C#\;%InstallRoot%\VC#\Snippets\%LCID%\Refactoring\;%MyDocs%\Code Snippets\Visual C#\My Code Snippets\
The quick fix for the snippets would be to provide the full path in place of the %MyDocs% setting.
I couldn't find a reference to how %MyDocs% is defined, but I suspect it's the "Projects Location" setting:
Tools -> Options -> Projects and Solutions/General

How to add a new file association to Visual Studio?

(Windows XP, Visual Studio 2010 Express (Web Developer))
I would like to add various file types to open in Visual Studio that it does not open by default, namely .js, .html, .shtml, .css, etc.
I tried looking for UI inside Visual Studio to add new file types, but I couldn't find anything, so I tried the naive approach of right clicking on the file -> Open With -> Choose Program -> Browse -> c:\program files\Microsoft Visual Studio 10.0\Common7\IDE\VWDExpress.exe. This almost works, except it starts a new instance of the IDE rather than opening a new tab the way .cs files do.
I've tried to go registry diving, exported the association for .cs files, and changing it to point to .shtml (for example), but this still spawns new windows.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.shtml]
"Content Type"="text/plain"
"PerceivedType"="text"
#="VWDExpress.cs.10.0"
[HKEY_CLASSES_ROOT\.shtml\OpenWithProgids]
"VSTA.cs.9.0"=""
"VWDExpress.cs.9.0"=""
"VWDExpress.cs.10.0"=""
[HKEY_CLASSES_ROOT\.shtml\OpenWithProgids\Shared]
#="Shared key to keep this from being removed with install/uninstall of side-by-side components."
[HKEY_CLASSES_ROOT\.shtml\PersistentHandler]
#="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
I strongly suspect that doing this is the wrong way to go about this, but I can't find a better solution. Is there one?
Ive had the same issue so downloaded VWD with SP1 along with VS.PHP 2.10. Right clicked on a .php file and chose 'open with vs.php 2.10', checked the checkbox on bottom which saves settings. Double clicking on a php file has been working since then. In order to be able to use it from a file manager like winscp i had to put 'explorer' as the editor executable. It works for my js html css and php files and opens them in the same VWD instance. Only pain may be that vs.php is to be paid for eventually and that you'd need to associate every extension you wish to work with.
After you use naive approach to associate file with VWDExpress.exe, find a command in registry and add /EDIT parameter. I don't know if this works for Express versions, but for full Visual Studio this opens file in already open Visual Studio instance.
Download Default Programs Editor and open.
In my case I was associating .php files to Visual Studio 11, and to do this I simply copied the settings for .cs files. I've noted all steps below.
FIle Type Settings > Context Menu
Search .php (or whatever association) - note you can multi-select
Click next
Click Add... under the list
Enter the following data:
Command name: Open
Program path: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" /dde
Now unfold the Advanced Settings, tick Use DDE Message, and click Edit. Add the following:
Message: Open("%1")
Application: VisualStudio.11.0
Topic: system
If you want to apply this to lots of files I suggest using the built in saving to registry option and creating a batch script with it.

Resources