When i try to load the repository in a space context I also get an error:
PS C:\Users\name> $client = New-Object Octopus.Client.OctopusClient($endpoint)
New-Object: Cannot find type [Octopus.Client.OctopusClient]: verify that the assembly containing this type is loaded.
Both of these errors do not occur with Octopus.Client but that library is not usuable for other reasons
Octopus Server v2022.3 (Build 10594)
Octopus.Server.Client.14.2.245
Am i incorrectly loading Octopus.Server.Client objects or have I encountered a bug?
Is the Powershell ISE running as an Admin? It looks like it’s possible the assembly is not getting installed properly.
Can I ask if there’s a specific reason you want to use Octopus Client rather than the API itself? Anything you can do in the Client you can do via the API (and more), and we have tons of resources for the API. I’m happy to help get you up and running with the API as well if you’re happy to go that direction.
We already have written a custom powershell module that abstracts some more complex actions behind powershell cmdlets.
This was all working fine with Octopus.Client until recent version upgrades broke some functionality.
We’d prefer not to have to refactor the entire module to use the rest API.
Note, I am experiencing this issue on multiple machines.
I’ve done some tinkering on my side and I can’t get it to work with Octopus.Server.Client either.
I’m going to reach out to the developers and get back to you as soon as I can. They are in Australia so we likely won’t hear back until tomorrow at the earliest.
This issue wasn’t as simple as we expected. It took some big brains to get around a dependency loop in the package managers and they identified that the following method should work.
I cleaned out all my nuget packages (you can just deleted them from C:\Program Files\PackageManagement\NuGet\Packages
So as you might be able to see, there was a package dependency loop which was unexpected - regarding NETStandard.Library. Installing NETStandard library separately with no dependencies allows Octopus.Server.Client to install without issues.
You shouldn’t need to remove all your Nuget packages but it’s an option if you are still having problems.
The engineers did more testing with the results I gave them and they found it’s not working for me and you because we’re using PowerShell 5 and they’re using PowerShell Core.
Unfortunately, Octopus.Server.Client has some dependencies which do not support .Net Framework (Noda Time), and because of that Octopus.Server.Client won’t work on PowerShell 5, and if you want to use Octopus.Server.Client it will need to be from core.
Please let me know if you’re able to test pwsh core and if it works for you.
Can you please delete everything in C:\Program Files\PackageManagement\NuGet\Packages(assuming this won’t hurt processes outside of you trying to use this script) and try the above? If you do get an error can you please paste your full output so i can pass it back to our developers?
If I omit the -Force parameter from this line
Install-Package Octopus.Server.Client -source https://www.nuget.org/api/v2
Then it works after manually approving the installation prompt.
With the -Force parameter (to bypasss the prompt) I get the error
Dependency loop detected for package ‘Octopus.Server.Client’.
Seems the Install-Package has some odd behaviour with force.
As this is to be installed in an automated environment the manual prompt suppression is a requirement so I am still stuck.
Thanks for the context. I tested that on my side and also get the dependency loop as well. Let me get with the engineers again and see if there’s a way to solve this.
If you replace the Install-Package Octopus.Server.Client -source https://www.nuget.org/api/v2 line with this it should go with no prompts and no error. You can remove the trusted source after the process is complete as well if you’re worried the settings will persist outside of the script.
After some tinkering I was able to get this to work.
Are there any plans to fix the original issue of the dependency loop or is the above code block expected to be the intended way to use Octopus.Server.Client from now?