如何从 Visual Studio 包 (VSIX) 检测解决方案或项目构建?

发布于 2024-11-03 18:35:35 字数 46 浏览 1 评论 0原文

如何从 Visual Studio 包 (VSIX) 检测解决方案或项目构建?

From a visual studio package (VSIX) how do I detect a solution or project build?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉生梦死 2024-11-10 18:35:35

如果程序集中有 Package 类,您可以执行以下操作:

DTE2 = Package.GetGlobalService(typeof(SDTE)) as DTE2;

然后查看 IsOpen 属性,查看解决方案是否打开...查看 Projects 属性以查找项目。

但是,如果您的意思是打开解决方案时如何获取事件...那么解决方案,例如:

public sealed class MyPackage : Package
{
  private DTE m_dte;

  protected override void Initialize()
  {
    IServiceContainer serviceContainer = this as IServiceContainer;
    m_dte = serviceContainer.GetService(typeof(SDTE)) as DTE;
    var m_solutionEvents = m_dte.Events.SolutionEvents;
    m_solutionEvents.Opened += SolutionOpened;
    ...

  }

  void SolutionOpened()
  {
     .... away you go...
  }
}

ref: VSIX: Getting DTE object ref: http://msdn.microsoft.com/en-us/library/envdte.solution.aspx

参考:http://msdn.microsoft.com/en-us/library/ envdte._solution.projects.aspx

If you have a Package class in your assembly, you can do:

DTE2 = Package.GetGlobalService(typeof(SDTE)) as DTE2;

Then look at then IsOpen property, to see if the solution is open... the look at the Projects property to find the projects.

However, if you mean you how do I get an event when a solution is opened... then Solutions, for example:

public sealed class MyPackage : Package
{
  private DTE m_dte;

  protected override void Initialize()
  {
    IServiceContainer serviceContainer = this as IServiceContainer;
    m_dte = serviceContainer.GetService(typeof(SDTE)) as DTE;
    var m_solutionEvents = m_dte.Events.SolutionEvents;
    m_solutionEvents.Opened += SolutionOpened;
    ...

  }

  void SolutionOpened()
  {
     .... away you go...
  }
}

ref: VSIX: Getting DTE object ref: http://msdn.microsoft.com/en-us/library/envdte.solution.aspx

ref: http://msdn.microsoft.com/en-us/library/envdte._solution.projects.aspx

小帐篷 2024-11-10 18:35:35

查看 DTE.Events.BuildEvents,其中有 OnBuildBeginOnBuildDone 事件。

Have a look at DTE.Events.BuildEvents there are events for OnBuildBegin and OnBuildDone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文