Hi Kartik,
I am not sure if I have hit the loading bug, however I realised there is a simple rule of thumb that should be made clear in your documentation about using the packaged Octopus.Client:
- When running PowerShell Core load from
\lib\netstandard2.0\
and…
- When running PowerShell prior version 6.0 load from
\lib\net45\
I’ll backtrack the context of my issue, it all started because I wasn’t able to load the Octopus.Client from the v7.0.0 package as I was getting dependency load errors!
For example trying to load the client type from the package:
try{
Add-Type -Path "C:\Temp\octopus.client.7.0.0.nupkg\lib\net45\Octopus.Client.dll"
}catch{
$_.Exception.LoaderExceptions | %{Write-Error $_.Message}
}
I was getting the following Loader Exceptions:
: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
You pointed me to the bug-fix Pull Request, however in has the fix made it in the package on Nuget.org and in which version?
I have just tried latest 7.1.0, which was pushed about 8 hours ago, and it seems to work just fine
The steps I took to try the latest Octopus.Client 7.1.0:
- In
C:\Temp
I pulled the package with the nuget command: nuget install -ExcludeVersion -OutputDirectory .
and the packages.config
in the folder has the follwing content:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Octopus.Client" version="7.1.0" />
</packages>
- Tried to load the Octopus.Client when running PowerShell v5.x:
Add-Type -Path 'C:\Temp\Octopus.Client\lib\net45\Octopus.Client.dll'
It loads just fine without a problem
However, there is a little gotcha - loading the dotnetcore type from when NOT running PowerShell Core it will manifest the same load exception errors
I guess you could update the documentation on this page here:
Loading Octopus.Client
I hope that helps another poor soul and may save some hair pulling …
Many Thanks,
Emil