SharpeRAD / Cake.Powershell

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

Could not load Cake.Powershell.2.0.0\lib\net6.0\Cake.Powershell.dll (missing System.Management.Automation, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) #95

Open ByteDev opened 1 year ago

ByteDev commented 1 year ago

I was under the impression from the Cake Powershell page that Cake 2.0.0 is supported but when I run: dotnet cake build.cake I get the following error:

Could not load Z:\Dev\GitHub\MyProj\build\tools\Addins\Cake.Powershell.2.0.0\lib\net6.0\Cake.Powershell.dll (missing System.Management.Automation, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)

I'm referencing Cake.Powershell via an addin in my cake file: #addin nuget:?package=Cake.Powershell&version=2.0.0.

Any idea of the problem? Any plans for Cake 3.0.0 support? Thanks

xiazhaozhao commented 9 months ago

解决了吗,我也碰到此问题,cake4.0

HariVamshi commented 6 months ago

I had the same issue with Cake.powershell 3.0.0 The package requires system.automation.7.3.3 and it has one of the dll missing

reureu commented 4 months ago

Hi there!

That's an interesting bug and it would be great if someone could solve it for good. But it might not be an easy one.

I have created a dummy test project to reproduce the bug. It is available in a separate repository.

This allowed me to find a workaround for this bug. Feel free to try it out.

In a few words:

  1. Add a cake.config file with these few lines:
    [NuGet]
    LoadDependencies=true
  2. Instead of only adding Cake.Powershell in your cake script, also add Microsoft.PowerShell.Commands.Management version 7.4.3
    #addin nuget:?package=Cake.Powershell&version=3.0.0
    #addin nuget:?package=Microsoft.PowerShell.Commands.Management&version=7.4.3
reureu commented 3 months ago

This bug seems to be resolved with Cake.PowerShell 4.0.0.

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!