Extending visual studio - c#

I want to write an AddIn for visual studio (2010). My goal is to add a menuitem to the context menu of all .cs files in the solution explorer. Or maybe just to context menu of the code window, although I prefer the first thing. I've been browsing around on the Visual Studio Extensibility website but I must admit that I'm having a hard time finding a tutorial on how to achieve what I want to. I guess that I don't really understand the VS extensibility model to be honest.
So I thought that some of the smart people here must have tried it before, and I'm hoping to save some time by asking here instead of fumbling in the dark.
Thanks in advance for any help.

I have a blog post on something pretty similar at http://www.runeibsen.dk/?p=237. Unfortunately, it is for VS2008 and AFAIK VS2010 is all WPF based now, in which case you may not be able to use it.

Checkout the codeproject Article-- LineCounterAddin, its a good one. Explaining the VS IDE internals needed to code Addins.
And quick googling shows this one Add-In That Converts C# Code To Visual Basic

Related

How to disable Quick Actions in Visual Studio?

I've googled extensively for this answer and it looks like being impossible. I've found a lot of people complaining and asking MS to make them optional since VS 2015, with no result. Like them, I think it's impossible to concentrate on your code with lightbulbs and screwdrivers flashing every time you move to another line. But I have a short story to tell.
I have been using VS 2015 for years, both at home and at work, and I have never seen those Quick Actions in my VS installations!
I remember to have tried VS 2017, and given up precisely because of those Quick Actions, which were absolutely new for me. Now I've taken a look at VS 2019, and they are still playing around.
Well, it seems I've found out what's different in my installations. When I right-click my C# code and click on Quick Actions I get this message:
.
The two computers have a quite different hardware, and in both I have made absolutely standard installations. I have never missed the Quick Actions, but although I have developed some quite complex applications, they were only for my own use. I've never published anything or tried to run them on other computers.
I really think I would like to also break Microsoft CodeAnalysis in VS 2019, so I could use the new features of C#.
You can disable CodeAnalysis for a project in the project properties> tab Code Analysis. For more details check this doc https://learn.microsoft.com/en-us/visualstudio/code-quality/disable-code-analysis?view=vs-2019.
As for the intelliSense, you can disable it by going to the tools menu > textEditor > C# > IntelliSense and uncheck the checkboxes.

No WPF User Control Library Template found in VS 2013

I am using VS 2013 (Express Version) and I want to create a WPF user Control Library project. But I am not able to find the template in my installed templates list. If I use Winforms, I am able to build a DLL out of my Winforms Application Project just by changing the Output type as "Class Library". But it is not happening in WPF and it is throwing errors if I do so. Is this the correct method of doing it or am I going wrong?
And in the Create New Project dialogue window, I am not able to find the .NET Framework selector drop down. After creating the project only I am able to change the .NET framework version by going inside the properties of the project.
Kindly help me to get out of this. Thanks in advance.
I have been working on this exact same problem for hours this morning. Here is what I think I have learned:
With Visual Studio Express 2013, it is by design that the WPF User Control Library template is not available for making a New Project. This is because it is the free Express version.
With the Express version, you don't have a "devenv.exe" for trying the "devenv /installvstemplates" to "fix" things. It is, instead, called (just a moment while I look this up again...) "WDExpress.exe" and will be located (if you have default location) in the "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE" directory. BUT - this won't help you. It won't fix your problem, because, as I mentioned, your Express installation is designed to not have that template available for New Project, so your "fix" won't put it there. I know this because this is what I tried myself. (Also, note that the instructions for doing this tell you to uninstall any extensions you've installed before doing it. And then, of course, if you still want them you have to reinstall them. Like I still have to do, incidentally.) I'm letting you know all of this so you don't go through the headache I'm having.
Note that I have not done this yet, so this is somewhat hypothetical on my part, but is based on my research on the Internet so far - Your solution is to create a WPF User Control Library manually [but now see UPDATE below]. (No, I don't know how to do this yet. I got into this in the first place, because I'm a WPF novice - just started working with it a few days ago - and late last night I got this great idea to add a "spinner" progress indicator to my "WPF play/learning project" I'm working on, and found a couple of relatively easy-to-work-with samples on the Internet - both of them are a WPF User Control Library - and at first I wanted to use the copy-and-paste to put the code in. But then I discovered... well, our mutual problem, because I'm using Visual Studio Express 2013. No such template under New Project. And literally at the tail end of my about-to-throw-in-the-towel, I'm googling and your post, Dhivakar, is already showing up with the right Google search.) So I haven't finished my research yet, but my next step is to learn exactly how to create a WPF User Control Library manually (the code and various project property settings), and then I can just save a WPF User Control Library skeleton for future use and document the details.
UPDATE: This guy totally has the solution for Express versions. I have followed his steps and it works great. The only additional piece of information I would add is that in my version (VSE2013), after you've created your WPF User Control Library template, when you open Visual Studio again and use File -> New Project, my selection in the tree (for a Windows app) came up under Templates -> Visual C# -> Windows (which is what I've been using). I did not see my template showing up there, after I created it, and I thought, "Great! Another piece of advice that doesn't work." But then I clicked up one on the "Visual C#" parent - and there was the template!
Here you go:
How to add a WPF control library template to Visual C# Express 2008
https://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/
Yes, it works this way for VSE2013 too.
UPDATE 2: I'm not absolutely positive about this, but I think he missed one little piece. In his step #4 he says to delete Window1.xaml and App.xaml. Maybe this didn't apply with VSE 2008, but in VSE 2013 there is also the App.config file which I believe is extraneous for our purpose. So you can delete App.config as well. As I said, I'm not absolutely certain about this yet, but I noticed that file in the project when I added a WPF User Control Library project to my solution, and I deleted it, and the solution compiled okay.
Try running devenv with the /installvstemplates switch, from https://msdn.microsoft.com/en-us/library/vstudio/ms247116(v=vs.100).aspx
If this doesn't work, browse to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplatesCache\CSharp\WPF\1033\WPFUserControl (this could change dependent upon your installation directory), open the .vstemplate file in a text editor, and make sure the setting is set to true, then try running devenv with the switch again.
Hope it helps.

New / Custom Visual Studio 2013 Language Service -Very Basic

I am not looking to do anything fancy just create a bucket for our internal company Visual Studio projects etc.
I have been through the following resources and it seems the codeplex projects have the same behavior as my tutorial walk throughs which tells me I don't understand / know what to look for / learn exactly.
Said behavior is that when my code or the codeplex code compiles and runs with no issues but I don't see the new language show up??? By show up I am expecting to see it in the New Project dialog under templates.
I started here:
http://msdn.microsoft.com/en-us/library/bb165744.aspx
and though not the best tutorial I feel I got everything correct. It compiles and runs but my new "Language" doesn't show.
So I did some more searching perhaps another tutorial might fill in some gaps I missed and I watched this video for an hour.
http://channel9.msdn.com/Blogs/VSIPMarketing/VSX212-Adding-a-Language-Service-into-Visual-Studio-2010
It's for 2010 but felt 2013 and 2010 close enough that it might help....and while I did learn quite a bit it didn't give me what I was expecting.
Another Google result was this SO post (How to create a new language for use in Visual Studio) from which I downloaded OOK from codeplex. Updated references, upgraded from 2010 to 2013 etc.
It compiles and runs but again my language is not "showing"....which is the behavior I had in my tutorial guided solution.
So what am I doing wrong??
All I really want is a language bucket where we can put our internal snippets, customized project templates etc. The c# editor, intellisense, syntax highlighting, etc. are just fine so don't need to extend those at this point.
If someone could please point me in the right direction I would be grateful.
Thank You

How do I create an installer for Visual Studio 2008 addin?

I have done an addin (in C#) for visual studio, (almost) ready to deploy it. But I don't know how to do an installer for that.
I saw the link here but I don't know where to go from there...
This seemed to be useful, but I don't understand where to start, put which code snippet where...
Can someone guide me from the basics? Can't find the resources online I want :(
Hope this helps, led me down the right path.
This is a real in depth from concept to implementation:
http://www.codeproject.com/KB/macros/LineCounterAddin.aspx
Found this also interesting:
http://social.msdn.microsoft.com/Forums/en/vsx/thread/cb5958f4-b503-456b-af24-ebfdde8ec6ad
http://www.mztools.com/articles/2008/MZ2008011.aspx
Wix is a great tool to deploy:
http://wix.sourceforge.net/votive.html
Any questions let me know.

Repository of Code Snippets

I'm just getting started with C# and often find myself going back to other projects and reusing some snippet of code in a new project.
Is there a good tool out there with which on can store all the little pieces of code they reuse again and again AND integrates with Visual Studio Express??
Visual studio has the concept of code snippets, under the tools menu there is a code snippets manager.
Almost forgot, to bring up the code snipped menu in code press CRTL+K+S.
Visual Studio Express is not legally extensible so I doubt there is a tool you can purchase or download that will integrate. However, snippy will help manage and create standard .snippet files for you, without integration.
It sounds like you may want to develop your own little framework that can be referenced by various projects.

Categories