SharpeRAD / Cake.Powershell

Powershell addin for Cake
http://cakebuild.net
MIT License
83 stars 36 forks source link

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

Closed holytshirt closed 2 weeks ago

holytshirt commented 3 years ago

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.

AdaskoTheBeAsT commented 3 years ago

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

holytshirt commented 3 years ago

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

SharpeRAD commented 3 years ago

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

holytshirt commented 3 years ago

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

alex-tsbk commented 3 years ago

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!

antonysmith-mando commented 2 years ago

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

zrhpwr commented 1 year ago

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

zrhpwr commented 1 year ago

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

andrei-perasaliak commented 1 year ago

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

reureu commented 4 weeks ago

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?

holytshirt commented 2 weeks ago

Hi @reureu I no longer have access to the scripts that I was working on with the issue. You can go ahead and close this. Thank you!

reureu commented 2 weeks ago

I cannot close it, but that's something @SharpeRAD can do.