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.

Community
  • 1
  • 1
talles
  • 14,356
  • 8
  • 45
  • 58

1 Answers1

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?

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • 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. – talles Oct 18 '13 at 06:01
  • @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. – nomen Apr 08 '19 at 21:54
  • This seems so wrong. I've been using EnvDTE almost exclusively running it from other assemblies or even PowerShell... – Filip Skakun Apr 07 '20 at 07:55
  • @FilipSkakun - but you do have a Visual Studio at the other end, don't you? – Simon Mourier Apr 07 '20 at 09:13
  • 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... – Filip Skakun Apr 08 '20 at 15:59
  • 1
    @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. – Simon Mourier Apr 08 '20 at 16:52