从C#代码执行的NuGet命令 [英] Execute a NuGet command from c# code
本文介绍了从C#代码执行的NuGet命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到一种方法来调用安装封装的mypackage
直接从C#代码。
我试过这样做,用C#的PowerShell,但我不是很熟悉。
谁能给我一个如何做到这一点的例子吗?
解决方案
您可以尝试这样的事情来执行PowerShell命令
命名空间:
System.Management.Automation
大会:
System.Management.Automation(在
system.management.automation.dll)
块引用>
私有静态无效RunPowershell(字符串命令)
{
变种的PowerShell = PowerShell.Create();
powerShell.AddCommand(命令);
powerShell.Invoke();
}
I'm trying to find a way to call an
Install-Package myPackage
right from C# code.I've tried to do so using powershell in c# but I'm not very familiar with it.
Can anyone give me an example of how to do so?
解决方案You could try something like this to execute powershell command
Namespace: System.Management.Automation
Assembly: System.Management.Automation (in system.management.automation.dll)
private static void RunPowershell(string command) { var powerShell = PowerShell.Create(); powerShell.AddCommand(command); powerShell.Invoke(); }
这篇关于从C#代码执行的NuGet命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文