您可以以编程方式执行“运行自定义工具”吗?在 C# 中的 ProjectItem 上?

发布于 2024-08-07 14:24:13 字数 99 浏览 3 评论 0原文

我想知道是否可以在 VS 解决方案中的文件上执行“运行自定义工具”?我已经有了 ProjectItem 对象。

信息:C#、Visual Studio 2010 SDK

I was wondering if it is possible to execute 'Run Custom Tool' on a file in the VS Solution? I have the ProjectItem object already.

info: C#, Visual Studio 2010 SDK

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

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

发布评论

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

评论(2

雪若未夕 2024-08-14 14:24:13

您需要确保选择 ProjectItem,然后运行:

DTE.ExecuteCommand("Project.RunCustomTool")

You'll need to ensure that the ProjectItem is selected, and then run:

DTE.ExecuteCommand("Project.RunCustomTool")
二智少女 2024-08-14 14:24:13

尝试将 ProjectItemObject 属性值转换为 VSProjectItem。如果不为 null,则只需对其调用 RunCustomTool() 即可。

// assumes you already have a ProjectItem projectItem that is **NOT** null
VSProjectItem vsProjectItem = projectItem.Object as VSProjectItem;
if (vsProjectItem != null)
{
    vsProjectItem.RunCustomTool();
}

Try to case the Object property value of a ProjectItem to a VSProjectItem. If not null, simply call RunCustomTool() on it.

// assumes you already have a ProjectItem projectItem that is **NOT** null
VSProjectItem vsProjectItem = projectItem.Object as VSProjectItem;
if (vsProjectItem != null)
{
    vsProjectItem.RunCustomTool();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文