envdte

Getting the macro value of project's TargetPath via DTE

一个人想着一个人 提交于 2019-12-07 12:10:30
问题 I need to get the absolute output path of the project's assembly via DTE. I tried doing this using this method, where I would access the OutputPath property, combining it with the assembly name, however this produces the relative path, such as: ..\..\Output\AnyCPU\Debug\MyAssembly.dll Using Path.GetFullPath is not good for me, because my project might be executing from another location. I noticed that the $(TargetPath) macro (in Build Events tab in project properties) contains the full path

Is there an event triggered when dte.Solution.SolutionBuild.StartupProjects changes?

前提是你 提交于 2019-12-07 08:00:33
问题 I am building a visual studio 2010 Add-in for internal use in my company. I would like to customize the main window caption to display the name of the current start up project. I can set the caption of the main window with the following code: DTE d = GlobalClass.dte2 as DTE; IntPtr hWnd = new System.IntPtr(d.MainWindow.HWnd); if (d.Solution.SolutionBuild.StartupProjects != null) { object[] sStartUpProject = (object[])d.Solution.SolutionBuild.StartupProjects; string Caption = d.MainWindow

Remove project from solution via Package Manager Console

丶灬走出姿态 提交于 2019-12-07 01:16:59
问题 I am trying to use powershell within the Package Manager Console to script the removal of a project from a solution and I am having a surprisingly hard time. I can easily add a project by PM> $dte.Solution.AddFromFile("C:\Dev\Project1.csproj") Now I want to be remove a project and can't get anything to work. I have tried a number of things including: PM> $project1 = Get-Project "Project1Name" PM> $dte.Solution.Remove($project1) > Cannot convert argument "0", with value: "System.__ComObject",

Unable to cast DTE, project or solution to VCProject and VCCodeModel

爱⌒轻易说出口 提交于 2019-12-07 00:21:53
问题 I am trying to get some information about c+= programs, through code. I have had some success with EnvDTE, now I need to use VCProject and VCCodeModel and I am running into casting problems (hope that is all...) In the working class, I have a DTE "application" passed from the Connect. I have: EnvDTE.Project project = application.SelectedItems.Item(1).Project; EnvDTE.Solution sol = (EnvDTE.Solution)application.Solution; I would like to use "project", not the first project in the solution as

Visual Studio Extension: Access VS Options from arbitrary DLL

雨燕双飞 提交于 2019-12-06 14:22:46
I'm currently developing my first VS extension, which needs to provide some options to the user. Following https://msdn.microsoft.com/en-us/library/bb166195.aspx , it was rather easy to come up with my own options page. However, I have not yet found out how to read my options. The solution structure of my extension is as follows: MySolution MyProject (generates a DLL from C# code) MyProjectVSIX Following the tutorial cited above, I have added a VS Package to my VSIX project and configured it as described. As a result, my options page with my options is shown under Tools/Options. Nice! Here's

DTEEvents.OnStartupComplete event not working for VSPackage (VSSDK2010)

拟墨画扇 提交于 2019-12-06 12:00:41
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? 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 _EventsObj; protected override void Initialize() { var dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); _EventsObj

Recursively traversing a Visual Studio Solution using PowerShell

痴心易碎 提交于 2019-12-06 10:59:24
问题 I need to programatically extract information from a solution which contains almost 150 projects in it. The solution file is not flat though, so some of the projects are organized into folders, the folder hierarchy can be more levels deep. This fits a recursive solution: I could write a function, which enumerates a list, and if the element is a project it would examine it, if it is a folder it would go into the folder and recursively call itself to examine the folder's content. The gist of it

Create a solution and add a project using “VisualStudio.DTE.10.0”

旧时模样 提交于 2019-12-06 09:33:22
I'm trying to create a VS2010 solution and add a project from a stand-alone app (not an add-in). I can create an instance of VS2010, but I'm not able to determine how to create a project properly...I can only find an example of how to create a project using the EnvDTE80 object, which later causes an exception because the project file is in an earlier format and needs to be upgraded. I have this: EnvDTE80.DTE2 dte2; object obj; System.Type t; t = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0", true); obj = System.Activator.CreateInstance(t, true); dte2 = (EnvDTE80.DTE2)obj; What I'm

How can an Empty Visual C++ project be created programmatically?

半城伤御伤魂 提交于 2019-12-06 06:42:19
I wanted to know how to use the template for an Empty Visual C++ project to programmatically create a new solution with this empty project. The code (C#) I have right now is: string VSProgID = "VisualStudio.Solution.10.0"; Type solnObjType = System.Type.GetTypeFromProgID(VSProgID, true); Solution4 soln = (Solution4) System.Activator.CreateInstance(solnObjType, true); soln.Create(@"C:\NewSoln", "New"); soln.SaveAs(@"C:\NewSoln\New.sln"); string emptyVCProjPath = soln.GetProjectTemplate("General/Empty Project", "VC++"); // Here's where I need help soln.AddFromTemplate(emptyVCProjPath, @"C:

Remove a keyboard shortcut binding in Visual Studio using Macros

三世轮回 提交于 2019-12-06 05:35:21
问题 I have a lot of custom keyboard shortcuts set up. To avoid having to set them up every time I install a new visual studio (happens quite a lot currectly, with VS2010 being in beta/RC) I have created a macro, that sets up all my custom commands, like this: DTE.Commands.Item("ReSharper.ReSharper_UnitTest_RunSolution").Bindings = "Global::Ctrl+T, Ctrl+A" My main problem is that Ctrl+T is set up to map to the transpose char command by default. So I want to remove that default value in my macro. I