envdte

Open DTE solution from another program (not add-in)

二次信任 提交于 2019-12-06 02:00:01
Is it possible to modify a solution, and use envdte tools, from a command-line project ? I have an add-in that modifies a solution. But... the changes are required for over a hundred projects... So I'd like to make a c# program that has the same logic, only it iterates through all solution files. The add-in starts with EnvDTE.Solution solution = (EnvDTE.Solution)application.Solution; where DTE2 application is passed from the add-in... How can I get the same solution, which then I query for projects... From a separate program, that will only know the solutionPath ? Is it possible to open the

How can I perform “Go To Definition” programmatically in Visual Studio?

非 Y 不嫁゛ 提交于 2019-12-06 00:26:46
问题 Given a string that represents a specific class/field/property (eg MyNameSpace.MyClass or System.String.Length ), how can I programmatically cause Visual Studio to go to that class/field/property (ie, make Visual Studio do the same thing that would happen if I was to type in the reference in the code editor and then hit F12)? 回答1: You probably need to do the following. Get the global IVsObjectManager2 interface (implemented by the SVsObjectManager object) Call IVsObjectManager2.FindLibrary to

Adding a custom build step with a nuget package

余生颓废 提交于 2019-12-05 23:12:42
问题 I am developing a nuget package which will set up the current project to use my company's assembly versioning standard. I've got it doing everything I want (so far) smoothly apart from adding in a custom build step. Historically this has been done manually by editing the .csproj file directly and adding in a couple of new tags into the xml. These are ... Property Group Target It actually adds them in successfully, but i've done it by editing the xml rather than via the EnvDTE object in the

Current type of the build action from Visual Studio - Microsoft.VisualStudio.Shell.Interop

左心房为你撑大大i 提交于 2019-12-05 23:10:15
In some extension we implement the IVsUpdateSolutionEvents2 and IVsSolutionBuildManager2 used for registering caller with the AdviseUpdateSolutionEvents For example, this called before any build actions have begun: public int UpdateSolution_Begin(ref int pfCancelUpdate) { ... } However, also need getting the status or type of the current build action, for example: build/rebuild/clean/deploy Available & known variants: BuildEvents With the Events.BuildEvents i can subscribe to OnBuildBegin, for example: _buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler((vsBuildScope

How to register key binding code on VSIX package installation

不想你离开。 提交于 2019-12-05 20:11:39
I'd like to add keyboard shortcut to Visual Studio package only once, during its installation. Basically I know how to do it from the package code, for example: var dte = GetGlobalService(typeof(DTE)) as DTE2; if (dte != null) { dte.Commands.Item("Tools.Something").Bindings = "Global::Ctrl+T, Ctrl+S"; } The problem is, I'd like to invoke this code only once (I don't want to execute this code in package class constructor, because it will execute each time the package will be used first time after VS restart). How to do it ? There is another way I wasn't aware last time. All what need to be done

Add an existing project to solution folder using PowerShell

末鹿安然 提交于 2019-12-05 18:22:32
问题 I'm working on a PowerShell script to dynamically create and add a Visual Studio project with its folders and assets to a solution. I'm using Visual Studio DTE. My directory structure on the file system is the following: C:\Dir1\Dir2\Stuff | +--Stuff <-- folder | | | `Stuff.csproj <-- existing project, included in sln | +--Subfolder <-- Subfolder in which I want to include my new csproj | +--Project1 <-- folder | | | | | `Project1.csproj <-- existing project, included in sln | | | +--Project2

How can I get only projects from the solution?

大城市里の小女人 提交于 2019-12-04 22:35:24
问题 I get a list of projects using following: var solution = (IVsSolution)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IVsSolution)); Refer following link for more details. But it gives me each and every item in the solution like Directories, projects, etc. I require only projects. How can I get only projects from the solution? 回答1: I tried and got the expected results. There may be other better solution but this actually works for me. var projects = CommonMethods.GetProjects

Recursively traversing a Visual Studio Solution using PowerShell

寵の児 提交于 2019-12-04 15:01:42
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: $dte = [System.Runtime.InteropServices.Marshal]::GetActiveObject("visualstudio.dte.11.0") function

Change the Debug properties of Visual Studio project programmatically by EnvDTE

荒凉一梦 提交于 2019-12-04 07:44:51
Is it somehow possible to change the project properties in debug section programmatically by EnvDTE classes? I know how to get the DTE instance and work with some of the settings, but I am blind or the debug section is just not accessible. I started from here http://msdn.microsoft.com/en-us/library/envdte.project.dte.aspx EnvDTE80.DTE2 dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.12.0"); Project project = dte2.Solution.Projects.Item(1); Configuration configuration = project.ConfigurationManager.ActiveConfiguration; configuration.Properties.Item

VSIX window - key shortcut to execute ICommand

北慕城南 提交于 2019-12-04 04:19:34
问题 Having a Visual Studio extension (VSIX) project: In Window we got UserControl , which have Button binded to some ICommand . This works perfectly as expected, however I would like to attach a key shortcut (e.g.: CTRL + S ) which would fire the same Command . I have checked several questions, in which I found the most useful this code: <UserControl.InputBindings> <KeyBinding Modifiers="Ctrl" Key="Esc" Command="{Binding SaveCmd}"/> </UserControl.InputBindings> However the Command is never fired