VSIX Project Context Menu - c#

I'm trying to create a Visual Studio 2017 extension, just for fun and to learn how VS extensibility works.
My extension must be usable from the Solution Explorer tab as a context menu button, but I would like to include it at a menu level that isn't root.
My goal is to put it in the "Add" sub-menu, but at the moment I'm only able to put it at root level (when you right-click the Project item, the menu entry is shown as the last of the context menu control).
How can I move it under the "Add" node?
Can it be done from the CommandPlacement tags I have configured in my .vsct file?

Use as parent of your command the IDG_VS_CTXT_PROJECT_ADD_ITEMS group id. If you are using CommandPlacement it would be:
<CommandPlacement guid="..." id="..." priority="0x0001" >
<Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_ADD_ITEMS"/>
</CommandPlacement>
Remember:
The parent of a group can be another group, a menu, a toolbar, a context menu, etc. either created by your extension or an existing one of VS, identified by prefix "IDM_". See GUIDs and IDs of Visual Studio menus and GUIDs and IDs of Visual Studio toolbars.
The parent of a command is always a group, never a menu, context menu or toolbar. The group can be new (created by your extension) or an existing group of Visual Studio, identified by prefix "IDG_". You have some built-in Visual Studio groups in the links above, but for a more exhaustive list install the ExtensionTools extension (Mads Kristensen) that provides intellisense in the .vsct file or check the source code of its VsctBuiltInCache.cs file.

I think and hope this might help, though it is a general answer and not a specific one. Learn by example.
I also hope the WiX authors won't mind, but I believe the source for their Visual Studio integration component "WiX Votive" is here: https://github.com/wixtoolset/VisualStudioExtension.
There is also this: https://github.com/wixtoolset/VisualStudio.wixext. I am not sure what this is to be honest. I should, but I don't. Mr.Arnson - I summon theee (WiX developer - The Matrix's got you).
WiX Votive - VS Integration is part of the overall WiX Toolset - which is a Windows Installer deployment solution capable of compiling MSI files from XML markup. MSI files are the binary deployment files used by Windows Installer for deployment on Windows.
If of interest you 1) download and install WiX itself (currently 3.11.1), and 2) download and install the correct Visual Studio integration (the marketplace links underneath the main download) making sure you get the correct version for your Visual Studio version - of course. Both downloads from the same link (or use the Visual Studio marketplace).
Here are some further details: WiX quick-overview.

Related

View the body of an assembly file(.NET 5) [duplicate]

I know that I can set up Visual Studio to debug through the .NET framework source code.
But is there a way that I can browse the code while NOT debugging - i.e., being able to press F12 or "Go to definition"?
I thought that if that feature isn't built into Visual Studio then there may be a plug-in that might add it?
There is a very new feature in Visual Studio 2017 version 15.6
You can see decompiled source code without any plugin! Btw, Ref12 doesn't work for VS2017.
Tools > Options , expand Text Editor > C# > Advanced, and enable "Enable navigation to decompiled sources (experimental)".
Ref: https://learn.microsoft.com/en-us/visualstudio/ide/go-to-and-peek-definition?view=vs-2017#view-decompiled-source-definitions-instead-of-metadata-c
With ReSharper it's possible to browse .NET sources by enabling ReSharper -> Options -> Tools -> External Sources -> Navigation to Sources.
After enabling this option new menu item "Navigate To -> Decompiled Sources" appears by right click on type/method/whatever.
Navigation also works with F12 for me.
I just discovered this extension that pretty much addresses my problem. The only thing is that it opens the source in the browser rather than in Visual Studio, but it's no big deal because even in the browser you can click the source code to navigate to types etc.
It was presented on Scott Hanselman's blog a couple of days ago:
Community member and fabulous coder Schabse Laks has created a Visual Studio extension for VS2010, 2012, and 2013! This extension sends calls to Go To Definition (or pressing F12 on a symbol) directly to the code online (when it's .NET Framework code, not yours).
You can download this companion "Ref12" Visual Studio Extension now! Just Goto Definition on any .NET type we have source for and it'll launch your default browser so you can explore the .NET Framework source yourself! Thanks Schabse!
Update:
As per the comments, for VS 2022 and .NET Core, use this fork of the extension: https://marketplace.visualstudio.com/items?itemName=EfreyKong.Ref12-VS2022
I downloaded the .NET Framework source code from here http://referencesource.microsoft.com/netframework.aspx.
Since I am working with .NET 4.0, I chose ".Net/4" from the list. (What is ".NET/8.0" in that list? No idea.)
I wrote some scripts to rearrange the bloody mess they give us:
Into a reasonable hierarchy of directories;
To remove duplicated code (why is every file doubled, or was my install bad?);
Rename all top-level namespaces to not conflict with native ones baked into Intellisense.
Example: System.Windows.Controls -> xSystem.Windows.Controls
Then follow these steps:
Create a new Visual Studio project of type "Class Library"
Remove all references -- yes, even the system ones.
Drag/drop all of your massaged .NET code into the root of your project.
Wait about 30 minutes for VS processing. VS will appear to freeze; be patient.
Intellisense/ReSharper still complains about heaps of problems, but now I can right click and select "Go to Declaration/Implementation".
Visual Studio is about 600MB with this project loaded.
I am using Visual Studio 2013 Ultimate.
1. Choose menu: TOOLS \ Extensions and Updates...
2. Choose Visual Studio Gallery \ Search Results. Search term: Ref12.
3. Download then install.
4. Restart Visual Studio.
5. Try: Click mouse on Class or method, press F12 and see result at http://referencesource.microsoft.com/
I've never tried this but supposedly the code is publicly available:
[Edit]
http://referencesource.microsoft.com/
There is the .NET Mass Downloader, but I think the straightforward answer to your question is, no.
However I now see Microsoft has made the code more easily downloadable.
Nevertheless note that even for your own code, when not debugging, unless you have the project open, VS does not help you locate source code (even though when you find it yourself break points will work when you start debugging again, if the .pdb files correspond).

Visual Studio 2017 change language of current file?

I have a *.cs.bak file that I want to temporarily (= no permanent settings) treat as C# in Visual Studio 2017.
I only found out that Visual Studio Code can do it, but looking to do the same in visual studio yielded no results, so I ask the internet about it.
You can just add it in your project with the add existing item. Inside VS just click on your csproj and select Add -> Existing item and select your .bak.
After that, If you click on the file in Solution Explorer and look at the Properties window, you'll see a property called "Build Action". This defines whether the file will be treated like code ("Compile"), included as a resource ("Embedded Resource"), ignored ("None")...

VS SetupProject registry entry for custom file-extensions

Within my project I create backup-files with a custom extension ".tp"
The software will be distributed with a Setup Project as an installer.
Which steps do I have to follow in order to add a registry entry via Setup project to let the OS show my custom icon? Is that possible?
I found a few solutions on how to do it manually, but I would like to have the installer (Setup project) to do it for me...
Could not find anything on that...
info:
I use Visual Studio Express 2017
Software is written in C#
EDIT:
In the meantime I was able to add a registry entry into the right directory, but I am not sure how to point to the .ico file, and on how to call SHChangeNotify...
Visual Studio setup projects have a File Types on Target Machine editor, so there's no need for registry manipulation. If you add a new file type (your .tp) the IDE's property window on the .tp (hit F4) will show a window where you add your icon. The %Open properties window is where you add the program to open the extension. It's not overly complicated. This seems to cover it in extra detail:
http://www.dreamincode.net/forums/topic/58005-file-associations-in-visual-studio/

Change the title of Solution Explorer in Visual Studio?

My job forces me to work in Visual Studio and .NET. I'm attempting to streamline the experience, somewhat successfully. (TFS still thwarts me.)
Right now, I want to work with multiple Solution Explorers, as we have a Visual Studio solution containing a multitude of csproj files. Creating a new Solution Explorer view for each commonly-used project would be great, except for this - all of the tabs and titles say "Solution Explorer".
Is there any way to change the title of the Solution Explorer window and tab? Is there any way to set the title to the title of the root solution or project file? (If there's an extension that will do this, I will happily install it.)
Thank you.
Edit: It looks like my question wasn't understood very well. The project conforms to regular standards - it's one Solution with multiple Projects, with a highly-nested directory structure. Basically, instead of having to scroll a lot, and constantly open and close nodes in the tree view, I'd like to have multiple Solution Windows to help facilitate this. Visual Studio provides an option called New Solution Explorer View in the context menu, which will open a new Solution Explorer window with a target object at its root. I want to do this for the commonly-used projects in my solution, but I want each Explorer instance to be named so that I can keep them in a single pane and click between them. Make sense?
Hope I've appeased the VS enthusiasts.
Double Edit: This is the feature I'm looking for. Is this possible through an extension?
There exists a visual studio-extension named Multiple Solution Explorer Tools, which extends the default behavior of the New Solution Explorer View-command:
Multiple Solution Explorer Tools Visual Studio Extension
New Solution Explorer instances gets persisted across solution unload and load.
The toolbar provides an icon () to rename the current solution explorer view.
The extension currently supports Visual Studio 2017 and 2019.

Add-in for Visual Studio for project file editing (csproj)

Do you know an add-in for visual studio which adds properties for C# projects?
csproj file format is very powerful but only small amount of options can be changed through the standard properties page. For instance, I want to have several configurations and each of them should include it's own references. Or I just want to change the type of project from winforms to wpf or other one. In order to do stuff like that developer has to edit csproj by hands in text editor instead of using properties.
If you know that such add-in doesn't exist, do you think that it could be popular on codeplex? or only small amount of developers realy need it? what is your opinion?
How is it going?
To edit project files inside of Visual Studio I use PowerCommands, but those things you can change "using properties" are those in Project Menu -> [Project Name] Properties. What PowerCommands does (among other things...) is allow you to easily edit the XML of a project opened inside Visual Studio so you get all the benefits of using Visual Studio to edit XML. Makes sense?
XML is hierarchical, so hardly you can fit it comfortably on a property list better than on a text editor.
About "I want to have several configurations and each of them should include it's own references", try creating templates for your projects, take a look there: Visual Studio Templates.
So... you are looking for addins at codeplex? why not take a look at http://visualstudiogallery.msdn.microsoft.com there are free and paid addins, an some form codeplex too. While you are on it, look for "Productivity Power Tools", "VSCommands 2010", "AllMargins" and "VS10x Code Map". I use them all, and they are certainly worth a look. [Hmmm... I also use CodeRush, you can get CodeRush Xpress for free from http://www.devexpress.com ;)]
Hope of being of help.
A little late to the table but I wanted to remove VSCommands 2010 because all I use it for really is the edit project file and I don't like to just have extensions hanging around if I am not using them. I discovered from this blog:
http://blogs.msdn.com/b/habibh/archive/2009/07/01/the-quickest-way-to-edit-a-visual-studio-project-file.aspx
"There is a quick and easy way of editing your Visual Studio project file. When a project is "unloaded", either because you explicitly chose to unload the project using the "Unload Project" command or Visual Studio failed to load the project for some reason (e.g. project upgrade failed), you can right click on the project in Solution Explorer and select the "Edit " command, as shown below."
It works like a charm!

Categories