I've got some powershell scripts that I need to run from time to time. I would like to have custom menu with few items where each would run some command. I also would like to have create this menu dynamically (the best - when VS run). Is it possible to achieve something like that? What should I read to achieve that? Maybe there are some external libraries which allow me to do that?
EDIT:
dynamically becouse I need some external programm to feed Visual Studio what items do I need and what script should be run.
Related
Actually editing *.cproj files manually, some code in the project template deletes my edits. So i'm forced to edit the file constantly before i build..
What way would you take to automate this:
is it possible to write a vs extension to have a custom tab in project options that reacts to checkboxes modifying project file for me
any other way?..
Thanks
automate editing project file
Something like a button or menu in VS, click it then some content which you used to add manually will be added into .proj file automatically? If I misunderstand, feel free to correct me:)
What way would you take to automate this:
Hard to say, but in short, I think it depends on whether you're experienced in extension development.
Since if you combine the functions into a extension. Every time when you want to add some custom changes to them, all you need to do is just click a button in VS or select a checkbox. It sounds good but the development of extension may take you some time and you may encounter some issues during the development.The journey could be challenging but instersting!
is it possible to write a vs extension to have a custom tab in project
options that reacts to checkboxes modifying project file for me
It's absolutely possible.Just take a look at this extension,it provides a function which edit project in VS.
Not sure the details how your ideal extension is. But I think you may get some help below:
1.Extend menus and commands if you want to start the function by menu command.
Also, you may get some help from this issue which gives the suggestion about how to put function button under Add-node in solution explorer.
2.Assuming you have function code which adds content into a .xxproj file.(This part is about developing, add nodes to xml-based proj file?).Then add that code into a event handle which will be called when clicking the button or menu.(Something like this)
So I think it's possible but may take some time. And it will be the most automatic way but it takes some time to develop. Anyway, hope it helps and good luck with you.
Visual Studio has a feature called Custom Tools. The Custom Tool will run every time I save a file or, if I click the "Run Custom Tool" menu item. Is there a way to make it run only when I click the Run Custom Tool menu item?
I don't believe there is any way to discriminate from within the custom tool code. This may be stating the obvious, but it sounds like a normal VS add-in would be more appropriate in your case.
In my Visual Studio extensibility project, I'm attempting to make my tool window visible upon launch after package installation.
The dotneteers describe a way of doing this that involves adding the following line to the package header (i.e. MyPackage.VSPackage.cs):
[ProvideToolWindowVisibility(typeof(MyToolWindow), Microsoft.VisualStudio.Shell.Interop.UIContextGuids80.NoSolution)]
Unfortunately, this doesn't work. It seems that Visual Studio doesn't pay attention to the "NoSolution" tool visibility directive (I can confirm that it does work for some of the other enumeration items, like Debugging, but this doesn't fit my use case).
If there's no way to make this auto-show the tool window on VS load, has anyone come up with any alternate (i.e. novel :)) solutions?
Alternatively, you can try making you package as auto load using ProvideAutoLoad and once at the Initialize() try to create this tool window. Use the Package.FindToolWindow() method.
I want to create an application.
It is about dealing with files and folders.
I want to create a command which will appear after right-clicking any file on Windows.
Is there any way to accomplish this by C#?
Or do I need to use a lower-leveled language to access those things?
Yes, you can certainly write Windows "shell extensions" in C# or any other .NET language. It is quite involved (have to write a Component Object Model (COM) DLL). There is a tutorial on it using the .NET 4 Framework: http://blogs.msdn.com/b/codefx/archive/2010/09/14/writing-windows-shell-extension-with-net-framework-4-c-vb-net-part-1.aspx
You can probably do everything you are trying to do with simple registry changes. Do a Google search for "Explorer right click context menu."
If you need that for yourself I think that a quick way to obtain that is to put a link to your program into the SendTo folder.
Update: Otherwise, here is a c# code sample that shows how to add the registry key.
If you are doing the visual studio thing then I'm assuming you want to deploy your app and make the installer sort out the context menu stuff. read this http://msdn.microsoft.com/en-us/library/k3bb4tfd%28v=vs.80%29.aspx
Background
I have a macro AttachToRemoteProcess that I use to attach the debugger to a running process on a remote computer. The macro use hard coded names for the process and the computer. I use the macro from a toolbar button on a custom toolbar. I consider this a sub par solution and I don't really like to have such a macro in my Visual Studio environment since it only works for the specific program/environment it was hard coded for.
I am using Visual Studio 2008.
Solutions
I can imagine two solutions but I do not know if they are possible to implement.
Alternative 1
I would like to either have the macro AttachToRemoteProcess being part of the solution (.sln) or one of the projects (.csproj) and have the toolbar appear when the solution or project has been loaded into Visual Studio. In this case it is OK to have hard coded settings such as process and computer name.
Alternative 2
The macro AttachToRemoteProcess is made reusable by taking process and computer as parameters.
The custom toolbar, button and the macro are always available in Visual Studio. This is just like my current solution, except for the parameterized macro.
When the button is clicked the computer name and process name is looked up from somewhere in the solution or the current project.
Questions
Would any of the alternative work and how can I go about doing it?
Are there any other alternative solutions for what I want to achieve?
The second alternative seems to work. Instead of retrieving the parameters from the solution (perhaps using VBA and the class EnvDTE.DTE.Solution), you could display a small form to select the process and computer and use this input as parameters to your macro. The button would be displayed in a personal toolbar all the time.
I'm not sure whether you can "attach" macros to particular solutions. If that's not possible, you will have no way to implement alternative 1.