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?
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.
I did not need to hack the .csprj file and add the reference line mentioned above. I do not have the Windows SDK installed.
I did do the Powershell copy mentioned above: Copy ([PSObject].Assembly.Location) C:\
My test with a Get-Process Powershell command then worked. I used examples from Powershell for developers Chapter 5.
System.Management.Automation on NugetSystem.Management.Automation.dll on NuGet, newer package from 2015, not unlisted as the previous one!
Microsoft PowerShell team packages un NuGet
Update: package is now owned by PowerShell Team. Huzzah!
If you don't want to install the Windows SDK you can get the dll by running the following command in powershell:
I couldn't get the SDK to install properly (some of the files seemed unsigned, something like that). I found another solution here and that seems to work okay for me. It doesn't require installation of new files at all. Basically, what you do is:
Edit the .csproj file in a text editor, and add:
to the relevant section.
Hope this helps.
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\
The assembly coming with Powershell SDK (C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0) does not come with Powershell 2 specific types.
Manually editing the csproj file solved my problem.