简体   繁体   English

Visual Studio添加自定义命令以在程序包管理器控制台中运行吗?

[英]Visual Studio add custom command to run in Package Manager Console?

I am trying to create a button which will automatically run few powershell commands which are imported in nuget package (tools in nuget package) 我正在尝试创建一个按钮,该按钮将自动运行一些在nuget包中导入的powershell命令(nuget包中的工具)

I found out how to add custom button in this question: How can I add a custom command to Visual Studio? 我在以下问题中发现了如何添加自定义按钮: 如何向Visual Studio添加自定义命令? . But I cannot find out how to run from this command in package manager console. 但是我无法在程序包管理器控制台中找到如何从此命令运行。

So is there a way to add custom command button to visual studio, which will start and run command in package manager console? 那么,有没有一种方法可以在Visual Studio中添加自定义命令按钮,从而在程序包管理器控制台中启动并运行命令?

Using a custom command described by link , you can run only external tools. 使用link描述的自定义命令,您只能运行外部工具。 In your case, you can run NuGet command line utility. 您可以运行NuGet命令行实用程序。 First, you need to download nuget.exe. 首先,您需要下载 nuget.exe。 Then you have to add a custom command, arguments for it and initial directory in External Tools dialog. 然后,您必须在“外部工具”对话框中添加自定义命令,其自变量和初始目录。 You can use solution variables (eg, $(ProjectFileName), $(SolutionDir)) for arguments and initial directory fields. 您可以将解决方案变量(例如$(ProjectFileName),$(SolutionDir))用于参数和初始目录字段。 You can use bat file to run few commands. 您可以使用bat文件运行一些命令。

Unfortunately, the NuGet command line utility has fewer features than package manager console. 不幸的是,NuGet命令行实用程序的功能少于程序包管理器控制台。 I don't know, is it enough of these features to solve your issue? 我不知道,这些功能足以解决您的问题吗?

To use all features of NuGet and to integrate into Visual Studio, you can implement your VSPackage . 要使用NuGet的所有功能并将其集成到Visual Studio中,可以实现VSPackage From VSPackage you can add at any place of Visual Studio the custom command (as a button or menu item). 在VSPackage中,您可以在Visual Studio的任何位置添加自定义命令(作为按钮或菜单项)。 When the command launch (user clicked your button), you can call any method of NuGet API inside Visual Studio. 当命令启动时(用户单击您的按钮),您可以在Visual Studio中调用NuGet API的任何方法。 This way requires time to develop and not so simple. 这种方式需要时间来开发而不是那么简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从visual studio命令提示符运行nuget包管理器控制台 - Run nuget package manager console from visual studio command prompt Package Visual Studio 中的管理器控制台未显示命令提示符 - The Package Manager Console in Visual Studio is not displaying the command prompt Visual Studio 包管理器控制台的键盘快捷键? - Keyboard Shortcut for the Visual Studio Package Manager Console? 在扩展中以编程方式访问visual studio的powershell控制台(包管理器控制台) - Access the powershell console (package manager console) of visual studio programmatically in an extension 如何通过PowerShell或命令行运行Visual Studio 2017程序包管理器命令 - How to run Visual Studio 2017 Package Manager commands through PowerShell or command line 在Visual Studio中的Package Manager控制台上更新多个包 - Update multiple packages on Package Manager Console in Visual Studio 如何在Visual Studio中更改程序包管理器控制台的字体大小 - How to change Font Size of Package Manager Console in Visual Studio 如何在 Visual Studio 外使用包管理器控制台 powershell - How to use Package Manager Console powershell outside visual studio 当我打开包管理器控制台时,Visual Studio 2015挂起 - Visual Studio 2015 hangs when I open the Package Manager Console 无法使用 Visual Studio NuGet 包管理器控制台安装包 - Cannot install packages using Visual Studio NuGet Package Manager Console
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM