Cake.Powershell icon indicating copy to clipboard operation
Cake.Powershell copied to clipboard

Cake tool error missing System.Management.Automation, Version=7.1.2.0

Open holytshirt opened this issue 3 years ago • 9 comments

Hi, Just want to say thanks for this project!

I saw you updated the powershell addin and just gave it a go and but seem to be getting this error

D:\dev\code\blah\[master ≡ +0 ~1 -1 !]> dotnet cake
Could not load D:\dev\code\blah\tools\Addins\Cake.Powershell.1.0.0\lib\net5.0\Cake.Powershell.dll (missing System.Management.Automation, Version=7.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)

I tried adding System.Management.Automation as a tool but made no difference.

Not sure what I'm doing incorrectly.

holytshirt avatar Mar 03 '21 23:03 holytshirt

hi when you add as addin Cake.Powershell do you also add &loaddependencies=true ?

AdaskoTheBeAsT avatar Mar 13 '21 16:03 AdaskoTheBeAsT

No I don't. Did not know about that. Will try when I'm back on my computer and let you know! Thanks!

holytshirt avatar Mar 13 '21 17:03 holytshirt

I've added System.Management.Automation back to the net46 in v1.0.1, hopefully that solves the problem for you.

SharpeRAD avatar Apr 05 '21 16:04 SharpeRAD

I've just double checked this and it works with &loaddependencies=true

I've tested in

PowerShell 7.1.2 &  5.1.19041.610
dotnet cake 1.1.0

With #addin "Cake.Powershell" I get

Could not load D:\dev\blah\blah\tools\Addins\Cake.Powershell.1.0.1\lib\net5.0\Cake.Powershell.dll (missing System.Management.Automation, Version=7.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
D:/dev/blah/blah/build.cake(166,17): error CS0103: The name 'StartPowershellFile' does not exist in the current context

With #addin nuget:?package=Cake.Powershell&loaddependencies=true It works

holytshirt avatar Apr 06 '21 10:04 holytshirt

Hi, we're using .NET 5, and I just want to continue a little on this thread - adding &loaddependencies=true actually pulls enormous amount of packages under /tools/addins - around 500Mb.

I'm wondering if there is any way to avoid specifying &loaddependencies=true.

Thank you!

alex-tsbk avatar Apr 27 '21 15:04 alex-tsbk

@alex-tsbk did you ever find a solution for this? Just hit the same problem with Cake 2.1.0....

antonysmith-mando avatar Feb 23 '22 06:02 antonysmith-mando

@antonysmith-mando how did you solve this? having the 500mb dependencies bundled for a deployment via cake is not nice..

zrhpwr avatar Sep 07 '22 11:09 zrhpwr

Solved it by using: #addin nuget:?package=System.Management.Automation&version=7.2.6 #addin nuget:?package=Microsoft.ApplicationInsights&version=2.21.0 #addin nuget:?package=Microsoft.PowerShell.CoreCLR.Eventing&version=7.2.6 #addin nuget:?package=Cake.Powershell&version=2.0.0

zrhpwr avatar Sep 07 '22 11:09 zrhpwr

Solved it by using: #addin nuget:?package=System.Management.Automation&version=7.2.6 #addin nuget:?package=Microsoft.ApplicationInsights&version=2.21.0 #addin nuget:?package=Microsoft.PowerShell.CoreCLR.Eventing&version=7.2.6 #addin nuget:?package=Cake.Powershell&version=2.0.0

It can be even shorter: #addin nuget:?package=System.Management.Automation&version=7.2.1 #addin nuget:?package=Microsoft.PowerShell.CoreCLR.Eventing&version=7.2.1 #addin nuget:?package=Cake.Powershell&version=2.0.0

andrei-perasaliak avatar May 23 '23 09:05 andrei-perasaliak

I reckon this bug is resolved in Cake.PowerShell 4.0.0, same as #95.

All you need to do is add Cake.PowerShell 4.0.0 as add-in with dependencies.

#addin nuget:?package=Cake.Powershell&version=4.0.0&loaddependencies=true

The &loaddependencies=true is required!

Can you please try?

reureu avatar Jul 30 '24 08:07 reureu