How to create GUIDs in Visual Studio 2013? I had an add in that worked well in VS2012 but it does not work in VS2013. I found this Create GUID in VS2012 and this How to convert VS2012 add ins to VS2013 Packages but could not make it work (add ins are not my forte - I simply edit SQL scripts). Is there an easy way to get back this functionality?
If you're using ReSharper (highly recommended), you can create new GUIDs everywhere by typing nguid
and pressing Tab.
Actually, uou can just use guidgen.exe which should get installed with VS.
Using menu TOOLS -> External Tools... add:
%Installation Path%\Microsoft Visual Studio 12.0\Common7\Tools\guidgen.exe
e.g.
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\guidgen.exe
Give the title of ‘Create GUID’ and it is there just as it was in VS2010.
The best tool / add-in for this is: http://visualstudiogallery.msdn.microsoft.com/22795583-5cc9-4681-af8e-6084f3441655
I was also wondering how I should do this. I saw the following example: Inserting a Guid for VS 2012. For VS2013 you have to install the SDK. Once you have done that you will see the template project items for packages and also for addins when you go to add a new project.
Despite the documentation saying that addins were deprecated in VS2013 they do appear to work (I am using VS2013 Ulitmate v 12.0.21005.1 REL). You can follow the instructions in the previous article.
I also created a package which was relatively straight forward too. Using How to: Convert an Addin to a VS Package I was able to create the package.
As in the article I added the following using statements:
using EnvDTE;
using EnvDTE80;
I then changed the MenuItemCallback method to the following:
private void MenuItemCallback(object sender, EventArgs e)
{
DTE2 dte = (DTE2)GetService(typeof(DTE));
if (dte.ActiveDocument != null)
{
TextSelection objSel = (EnvDTE.TextSelection)(dte.ActiveDocument.Selection);
objSel.Insert(Guid.NewGuid().ToString());
}
}
After building the project I went to the bin\Debug folder and started the vsix file (GuidPackage.vsix in my case). This installed the package for use in the IDE.
I now have a menu item to insert guids into my code and am able to create a shortcut key stroke for it in the usual way.
Just use PowerShell from VS Package Manage Console:
- Switch to Package Manager Console (or you can open PowerShell cmd).
- Execute
[guid]::NewGuid()
.
Result:
Guid
----
61dabfd8-9151-46f5-8d92-72306044d844
I prefer to use this solution:
_TUCHAR *guidStr = 0x00;
GUID *pguid = 0x00;
pguid = new GUID;
CoCreateGuid(pguid);
// Convert the GUID to a string UuidToString(pguid, &guidStr);
delete pguid;
One other tool that I came by was this extension. Works pretty good
"Insert new GUID" (Shift+Alt+G): Inserts a new GUID at the current position.
"Insert last GUID" (Ctrl+Shift+Alt+G): Re-inserts the last new GUID at the current position.
© 2022 - 2024 — McMap. All rights reserved.