【问题标题】:Execute NuGet PowerShell Command by code通过代码执行 NuGet PowerShell 命令
【发布时间】:2014-11-17 08:05:00
【问题描述】:

我有一个带有 PowerShell 命令的 NuGet 包。

我想从上下文菜单中管理它(添加了 vsix)。使用 NuGet.VisualStudio,我可以通过代码安装我的 NuGet 包,但我不知道如何执行 NuGet 包 PowerShell 命令。

谁能帮帮我?

谢谢

马修

【问题讨论】:

    标签: powershell nuget visual-studio-extensions


    【解决方案1】:

    您可以使用 IScriptExecutor 在 NuGet 包中执行 powershell 脚本。

    【讨论】:

    • 听起来正是我需要的。非常感谢!但是,我不确定使用它的方式。例如,在我的 NuGet PowerShell psm1 中,我有 function Foo1($param1) { } Export-ModuleMember Foo1 function Foo2($param1, $param2) { } Export-ModuleMember Foo2 How to call Foo2 "p1" "p2" using scriptExecutor。执行脚本方法?非常感谢您的帮助
    • 看来我误解了你的问题。 IScriptExecutor 可用于执行 NuGet 包中 的 powershell 脚本文件。在您的情况下,您想要执行任意的 powershell 脚本。如果这是您想要做的,那么抱歉,NuGet 不支持。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2011-09-19
    • 2015-04-08
    • 1970-01-01
    • 2018-11-09
    • 2022-07-07
    • 1970-01-01
    相关资源
    最近更新 更多