Search code examples
c#.netvisual-studiopowershellsharpdevelop

How do I use SharpDevelop's PackageManagement.Cmdlets in powershell


I'm trying to use the PackageManagement cmdlets that come with SharpDevelop 5.1, but i'm running into a problem.

This is what i've tried

import-module ".\PackageManagement.Cmdlets.dll"

$solution = "C:\Git\TestProject\TestProject.sln"

$project = Get-Project TestProject $solution

This results in a TypeInitializationException

System.TypeInitializationException: The type initializer for 
'ICSharpCode.PackageManagement.PackageManagementServices' threw an exception.
---> ICSharpCode.Core.ServiceNotFoundException: Required service not found: 
ICSharpCode.Core.IPropertyService

I have also tried loading the dll in through reflection:

[Reflection.Assembly]::LoadFrom(".\PackageManagement.Cmdlets.dll") | Out-Null

$test = New-Object ICSharpCode.PackageManagement.Cmdlets.GetProjectCmdlet

Which resulted in the same exception.

Looking at fusion logs, looks like the following libraries are loaded:

PackageManagement

NuGet.Core

ICSharpCode.SharpDevelop

ICSharpCode.Core

It doesn't look like the Cmdlets themselves are being loaded.

What am I doing wrong?


Solution

  • You cannot use the PackageManagement.Cmdlets.dll on its own from the PowerShell command line. It depends on parts of SharpDevelop that need to be initialized before being used.

    A long time ago I created a version of SharpDevelop 4 and the NuGet PowerShell cmdlets that you could use from the command line with PowerShell. This work was never ported to work with SharpDevelop 5.