Using the EnvDTE assembly
Asked Answered
S

1

7

Is it possible to use the EnvDTE assembly in a non-extension project (e.g. a Class Library project)?

If so, how would I access the ConfigurationManager.ActiveConfiguration property?

This question answers exactly what I want, but I couldn't get the dte object that it uses.

Stillmann answered 14/10, 2013 at 22:33 Comment(0)
H
5

EnvDTE only works from within Visual Studio, if that's what you mean.

However, you can control Visual Studio programmatically (using COM monikers you can access to a given Visual Studio instance remotely). Check these blog posts here: How to start Visual Studio programmatically and How to get DTE from Visual Studio process ID?

Heavyduty answered 15/10, 2013 at 6:13 Comment(6)
I was hoping that the configuration name I used when building was written in the resulted assembly and, somehow, I wanted to get it at runtime. Or at least get it at compile time and inject it to my code. But it seems, as you said, it only works whithin Visual Studio.Stillmann
@talles: my understanding is that you can use EnvDTE in a T4 template, which would let you inject values into your source at compile time.Wheel
This seems so wrong. I've been using EnvDTE almost exclusively running it from other assemblies or even PowerShell...Mythopoeic
@FilipSkakun - but you do have a Visual Studio at the other end, don't you?Heavyduty
Exactly - other end. I just want to make sure people are not misled here. :) You can just do stuff like this in PowerShell: $dte = New-Object -ComObject VisualStudio.DTE; $dte.MainWindow.Visible = $true; $dte.UserControl = $true Now I'm here because I'm trying to figure out how to retrieve DTE for existing instances with PowerShell... I've been doing that for years with C#, but PS gets confused with GetRunningObjectTable. I know - a separate question...Mythopoeic
@FilipSkakun - yes, that's what I meant by "within Visual Studio", you always need a Visual Studio instance running, but it can be accessed remotely.Heavyduty

© 2022 - 2024 — McMap. All rights reserved.