visual-studio 在 Visual Studio 中引用 system.management.automation.dll

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1186270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:48:34  来源:igfitidea点击:

Referencing system.management.automation.dll in Visual Studio

visual-studiopowershell

提问by icelava

I am beginning to look into the PowerShell model and snap-in development. The first thing I notice is to reference System.management.automation.dll. However in Visual Studio, the .NET tab does not have that assembly, and nor is one able browse to

我开始研究 PowerShell 模型和管理单元开发。我注意到的第一件事是引用 System.management.automation.dll。但是在 Visual Studio 中,.NET 选项卡没有那个程序集,也不能浏览到

C:\windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll

C:\windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll

to make a file-based reference.

进行基于文件的参考。

Am i forced to copy the file out manually to make an easy reference?

我是否被迫手动复制文件以方便参考

回答by skfd

System.Management.Automation on Nuget

Nuget 上的 System.Management.Automation

System.Management.Automation.dll on NuGet, newer package from 2015, not unlisted as the previous one!

NuGet 上的 System.Management.Automation.dll,是 2015 年的更新包,与之前的包一样未列出!

Microsoft PowerShell team packages un NuGet

Microsoft PowerShell 团队打包 un NuGet

Update:package is now owned by PowerShell Team. Huzzah!

更新:包现在归 PowerShell 团队所有。哈扎!

回答by tomasr

A copy of System.Management.Automation.dll is installed when you install the windows SDK (a suitable, recent version of it, anyway). It should be in C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\

安装 Windows SDK 时会安装 System.Management.Automation.dll 的副本(无论如何都是合适的最新版本)。它应该在 C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\

回答by kravits88

If you don't want to install the Windows SDK you can get the dll by running the following command in powershell:

如果您不想安装 Windows SDK,您可以通过在 powershell 中运行以下命令来获取 dll:

Copy ([PSObject].Assembly.Location) C:\

回答by JP.

I couldn't get the SDK to install properly (some of the files seemed unsigned, something like that). I found another solution hereand that seems to work okay for me. It doesn't require installation of new files at all. Basically, what you do is:

我无法正确安装 SDK(某些文件似乎未签名,诸如此类)。我在这里找到了另一个解决方案,这对我来说似乎没问题。它根本不需要安装新文件。基本上,你要做的是:

Edit the .csproj file in a text editor, and add:

在文本编辑器中编辑 .csproj 文件,并添加:

<Reference Include="System.Management.Automation" />

to the relevant section.

到相关部分。

Hope this helps.

希望这可以帮助。

回答by pradeep

if it is 64bit them - C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell**3.0**

如果是 64 位 - C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell**3.0**

and version could be different

和版本可能不同

回答by dpminusa

I used the VS Project Reference menu and browsed to: C:\windows\assembly\GAC_MSIL\System.Management.Automation and added a reference for the dll and the Runspaces dll.

我使用了 VS Project Reference 菜单并浏览到:C:\windows\assembly\GAC_MSIL\System.Management.Automation 并添加了对 dll 和 Runspaces dll 的引用。

I did not need to hack the .csprj file and add the reference line mentioned above. I do not have the Windows SDK installed.

我不需要破解 .csprj 文件并添加上面提到的参考行。我没有安装 Windows SDK。

I did do the Powershell copy mentioned above: Copy ([PSObject].Assembly.Location) C:\

我确实做了上面提到的 Powershell 副本: Copy ([PSObject].Assembly.Location) C:\

My test with a Get-Process Powershell command then worked. I used examples from Powershell for developers Chapter 5.

我使用 Get-Process Powershell 命令进行的测试然后起作用了。我在第 5 章中使用了来自 Powershell 开发人员的示例。

回答by Radu

The assembly coming with Powershell SDK (C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0) does not come with Powershell 2 specific types.

Powershell SDK (C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0) 附带的程序集不附带 Powershell 2 特定类型。

Manually editing the csproj file solved my problem.

手动编辑 csproj 文件解决了我的问题。

回答by NOWAN

You can also use nuget: https://www.nuget.org/packages/System.Management.Automation/It is maybe a better option.

您也可以使用 nuget:https://www.nuget.org/packages/System.Management.Automation/ 这可能是一个更好的选择。