1

In Powershell v5.1... If I install a .NET NuGet package (example: redmine-api) using this command:

Install-Package redmine-api

How do I then create a new object from that package for use in Powershell?

I've tried:

Add-Type -AssemblyName Redmine.Net.Api
# OUTPUT: Add-Type : Cannot add type. The assembly 'Redmine.Net.Api' could not be found.

[reflection.assembly]::LoadWithPartialName("Redmine.Net.Api")
# OUTPUT: (no ouput)

$rdm = New-Object Redmine.Net.Api
# OUTPUT: New-Object : Cannot find type [Redmine.Net.Api]: verify that the assembly containing this type is loaded.
Adam
  • 111
  • 5

1 Answers1

0

As pointed out by @Matthew, it wasn't working as I was trying to load the namespace into the object. The correct method is:

[reflection.assembly]::LoadWithPartialName("Redmine.Net.Api")
$rdm = New-Object Redmine.Net.Api.RedmineManager

Looking at the package's docs, the Assembly name relates to using Redmine.Net.Api and the object name relates to new RedmineManager(host, apiKey) in C# source code.

Adam
  • 111
  • 5