envdte

How to get list of projects in current Visual studio solution?

ぃ、小莉子 提交于 2019-12-17 10:44:57
问题 When we open Package Manager Console in any open solution, it shows all the projects of that solution. How it is loading all the projects of the same solution. When I tried with below shown code it is fetching me projects of the first solution which I have opened. private List<Project> GetProjects() { var dte = (DTE)Marshal.GetActiveObject(string.Format(CultureInfo.InvariantCulture, "VisualStudio.DTE.{0}.0", targetVsVersion)); var projects = dte.Solution.OfType<Project>().ToList(); return

WindowState change event in Visual Studio extension

谁说我不能喝 提交于 2019-12-13 06:19:03
问题 I am looking for an event that will notify me when the main window is minimized and restored in a Visual Studio extension package. I've looked at the DTE2.Events, as well as the IVsWindowFrame and IVsWindowFrameNotify interfaces but don't see anything that will do what I need. 回答1: Get the HWND of the VS window: HWnd of Visual Studio 2010 Capture the messages being sent to Visual Studio: C# - Capturing Windows Messages from a specific application Then wait for a WM_SIZE message: http://msdn

Respond to dialog boxes using DTE.ExecuteCommand

丶灬走出姿态 提交于 2019-12-12 18:41:20
问题 Is there a way to say Yes or No or OK to a dialog/message box while opening Visual Studio 2015 using EnvDTE ? I've tried debugging my application while the box is open but I have no idea what to look for. I've also tried searching within this list of commands but cannot find anything that responds to a message box. I am using code based on this Microsoft guidance to open an instance of Visual Studio, open a solution and then run commands against it. The messages that come up upon opening my

VS Extension: TextPoint.GreaterThan / LessThan very slow for large files

帅比萌擦擦* 提交于 2019-12-12 10:47:49
问题 I'm working on a VS Extension that needs to be aware of which class member the text-cursor is currently located in (methods, properties, etc). It also needs an awareness of the parents (e.g. class, nested classes, etc). It needs to know the type, name, and line number of the member or class. When I say "Type" I mean "method" or "property" not necessarily a ".NET Type". Currently I have it working with this code here: public static class CodeElementHelper { public static CodeElement[]

How do you walk the solution hierarchy?

*爱你&永不变心* 提交于 2019-12-12 04:57:04
问题 I've been working on this about 14 hours now. It is totally driving me crazy. Without referencing any custom dlls I want to walk $dte.Solution.Projects for either projects or projectitems to check if $SourceControl = get-interface $dte.SourceControl ([EnvDTE.SourceControl]) $SourceControl.IsItemUnderScc() Things like solution folders get in the way. I've done this just fine in C# repeatedly (and in F#), I just can't seem to do it in powershell. I have done it both (C#) via Dte.Solution and

Activate Visual Studio's Output window using DTE

ぐ巨炮叔叔 提交于 2019-12-11 13:43:54
问题 I've created a custom output window pane for my VSPackage : Using this code: // Creating Output Window for our package. IVsOutputWindow output = GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; Guid guildGeneral = Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.GeneralPane_guid; int hr = output.CreatePane(guildGeneral, "Codex", 1, 0); hr = output.GetPane(guildGeneral, out ApplicationConstants.pane); ApplicationConstants.pane.Activate(); QUESTION How can I select the Output tab

Adding programmatically in C# a project reference (as opposed to an assembly reference) via EnvDTE

可紊 提交于 2019-12-11 03:07:29
问题 In visual studio when you add a reference to an existing project in your solution in the .csproj file it ends up like so: <ProjectReference Include="..\TestProject2\TestProject2.csproj"> <Project>{15EC8369-B0C5-4F71-A366-19042F450A2D}</Project> <Name>TestProject2</Name> </ProjectReference> If I add a reference to an assembly DLL via EnvDTE: var p = _project as VsProject; p.References.Add(<path to assembly DLL>); it ends like this: <Reference Include="TestProject2.csproj"> <HintPath>..

Get all code statements in specific code element with EnvDte

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 02:06:48
问题 By code statement i mean smallest standalone element of code. Is there an interface to get code statements inside a EnvDTE.CodeFunction body in a structured form. There are ways that can retrieve body of EnvDTE.CodeFunction as plain text, and if i want to process method calls etc. i should use Regex which i think is not a general solution. For example both of these statements are same: var value = @"the "" is qoutation mark"; var value = "the \" is qoutation mark"; but it is a little hard to

How do I list all the projects in the current solution using EnvDTE?

℡╲_俬逩灬. 提交于 2019-12-10 11:28:58
问题 I've been following MSDN's Hello World guide to developing Visual Studio extensions (this article specifically deals with creating one as a Visual Studio toolbar command). I am trying to list all projects contained in the current/active solution. In the auto generated code for the Command template. I have tried EnvDTE 's Solution 's Projects property, but it shows zero projects. There is a ActiveSolutionProjects property as well, but it also shows an empty array. How is this achieved ? P.S.:

DTEEvents.OnStartupComplete event not working for VSPackage (VSSDK2010)

北慕城南 提交于 2019-12-10 11:12:01
问题 In the Package constructor I added the event handler for OnStartupComplete event. But when I run the code, the the event handler is not called. What am I doing wrong? 回答1: There's a bug in VS that recycles the DTEEvents object (with your event handlers) unless you keep an explicit reference to it. You need something like this: [ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string)] [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string)] class MyPackage : Package { DTEEvents