Referencing system.management.automation.dll in Visual Studio

Viewed 156373

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

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?

9 Answers

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\

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

and version could be different

As @skfd alludes to above, the System.Management.Automation.dll package is available on NuGet if you are targeting .Net 4.8 or earlier, but is now delisted, so you need to install it manually. eg:

PM >Install-Package System.Management.Automation.dll -Version 10.0.10586

The System.Management.Automation package is also available if you are targeting .Net Core or Framework 5/6 and seems to be the supported package moving forward. You could also try installing this package and adding the reference manually, but YMMV.

Related